Question

My Code is:

 <a href='<%# Eval("websitename")%>' runat="server" target="_blank">
 <asp:Label runat="server" Text='<%# Eval("websitename")%>'></asp:Label>
 </a>

I will bind website name from code behind, when i click that it searches that website inside my local host.

if that website name is "www.stackoverflow.com" it open like "localhost:1234/www.stackoverflow.com

How to redirect to www.stackoverflow.com.

Thanks in Advance

Was it helpful?

Solution 2

Check if websitename starts with http:// and if not, add it.

Or if websitename never starts with http://, just do

<a href='<%# "http://" + Eval("websitename")%>'

OTHER TIPS

Add http:// to the beginning of the address:

 <a href='http://<%# Eval("websitename")%>' runat="server" target="_blank">
       <asp:Label runat="server" Text='<%# Eval("websitename")%>'></asp:Label>
 </a>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top