问题
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