0

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

Chris S
  • 64,770
  • 52
  • 221
  • 239
Learner
  • 346
  • 1
  • 6
  • 16
  • You should add http:// at the beginning of your "websitename". This tells your browser to use http protocol instead of localhost. – ankur140290 Feb 04 '13 at 13:00

2 Answers2

1

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>
Blachshma
  • 17,097
  • 4
  • 58
  • 72
0

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")%>'
Raphaël Althaus
  • 59,727
  • 6
  • 96
  • 122