Click here to Skip to main content
16,015,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want that a site address typed in textbox should serve as a link to that site when viewed as webpage. In normal course it appears as a text. I am using ASP.NET with C#.

I have seen this happen at Facebook but I was not able to find and code or tutorial to implement this on my site.

I am looking for any kind of help to implement it.

Kindly help me.

Many thanks.
Posted

1 solution

 
Share this answer
 
Comments
Member 10235977 12-Mar-14 7:25am    
Sorry for my ignorance but I need some more elaboration.
I tried a simple page. My Default.aspx page has

<asp:TextBox ID="TextBox1" runat="server">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label">
and my code behind (Default.aspx.cs) has
protected void Button1_Click(object sender, EventArgs e)
{
Uri myuri = new Uri(TextBox1.Text, UriKind.Absolute);
Label1.Text = myuri.ToString();
}
When I run this application, I get the error

"System.UriFormatException: Invalid URI: The format of the URI could not be determined"

Kindly help me with further details to enable me to use this technique.
Krunal Rohit 12-Mar-14 10:11am    
May be you are not using a proper URL there. Either for Authentication, Transfer or any other purpose - the url formed and used is not valid. Make sure to form a proper URL(relative) referrenced to root directory if the page exists in the project or absolute URL if outside.

your textbox must have value something like - www.google.com :)

-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900