views:

3285

answers:

8

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?

Thanks

A: 

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.

Ian Jacobs
+1  A: 

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.

Ryan Montgomery
+5  A: 

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

Daok
A: 

Found this project that might do what you want. I haven't needed to show the link rather than the URL before, but this seemed like a possible solution.

itsmatt
+1  A: 

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.

doug
A: 

Are we talking about ASP.NET or Windows Forms?

Vilx-
+2  A: 

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

Bruno Costa
Quick and easily done.
Ron Warholic
A: 

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