How do I add HTML links in C# TextBox?

血红的双手。 提交于 2019-12-23 20:43:20

问题


How can I put a link in a C# TextBox? I have tried to put HTML tags in the box but instead of showing a link it shows the entire HTML tag. Can this be done with a TextBox?


回答1:


I would think about this a little bit. If you allow executable code in an editable control, the user, the user can execute ANY code. This is generally a bad idea.

The behavior of the C# control is intentional to prevent the exact behavior that you are trying to create. A little creativity (such as parsing out links from the text box and creating a list of links next or below the text box) will provide a much safer application.




回答2:


Use the RichTextBox, no need to build your own, it cames with VS




回答3:


I would try using an editable div and making it look like a text box. This would allow you to get user input and use links.

To make this easier, try JEditable.




回答4:


If that is in windows forms and you really can't use the richtextbox, you can create a control with a linklabel inside of textbox.

http://www.codeproject.com/KB/miscctrl/LinkTextBox.aspx




回答5:


To my knowledge not with the standard textbox. You'd have to create your own. One option it the Telerik controls, they're a little pricey for individual development, but very robust and configurable.




回答6:


For windows application, we can use a webbrowser control. However, for web applications Freetextbox will do the job.This is freely available dll.



来源:https://stackoverflow.com/questions/330850/how-do-i-add-html-links-in-c-sharp-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!