happysmile
happysmile

Reputation: 7777

how to open new IE window on click of hyperlink

" Text="<%#Eval('name')%>" Target="_blank" runat="server" />

here the text that i have binded to navigate url can be any url (eg:asp.net,google.com)

this is my code when i try to open a new iE window

as my file is under an directory admin/abc.aspx

now in the url it opens like this: http://localhost:5655/admin/www.asp.net

but in the url should be like this www.asp.net so that this website opens

any help would be great

thank you

Upvotes: 0

Views: 2687

Answers (6)

Bharath Krishna
Bharath Krishna

Reputation: 31

It's pretty simple. Set the "Target" attribute of your asp:HyperLink to "_blank". Fill the url into NavigateUrl. It's going to open the link in a new Browser.

 <asp:HyperLink runat="server" ID="lnkUrlValue" NavigateUrl='<%#Eval("Url")%>'  
  Text='<%#Eval("Url")%>' ForeColor="#8D34FF" Font-Underline="true")                                                                                                                   
  Target="_blank"></asp:HyperLink>

Upvotes: 3

Anuraj
Anuraj

Reputation: 19598

Did you tried this

NavigateUrl='<%# "http://" + Eval('name')%>' 

Upvotes: 0

happysmile
happysmile

Reputation: 7777

final answer

" Text="<%#Eval('name')%>" Target="_blank" runat="server"/>

NavigateUrl='<%# "http://" + Eval('name')%>'

Upvotes: 0

Himadri
Himadri

Reputation: 8876

Try the following:

<asp:HyperLink
  id="hyperlink1"
  NavigateUrl="<%# (Eval("URL").ToString().IndexOf("http://")!=-1 ? "http://":"")+Eval("name").ToString()%>"
  Text="<%#Eval('name')%>"
  Target="_blank"
  runat="server" />

Upvotes: 0

Klaus Byskov Pedersen
Klaus Byskov Pedersen

Reputation: 120937

remember to begin your urls with http:// otherwise it will think it's a relative url.

Upvotes: 4

leepowers
leepowers

Reputation: 38308

Make sure the URL starts with a protocol like http://

Upvotes: 2

Related Questions