Click here to Skip to main content
15,913,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi

I have a hyperlink inside a gridview. Iam attempting to open the link on a new window. I found below code which works. However the #039 removes all "\". If I remove the #039, the code does not build. Any thoughts how to make this work?

It has to be a simple fix but I have spent much time unable to get this working.

Many thanks in advance.

XML
<ItemTemplate>

<asp:HyperLink  ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("FileLink", "javascript:openWindow(&#039;{0}&#039;);") %>' Text='<%# Eval("Name") %>' /> </asp:HyperLink>

</ItemTemplate>


My javascript function is

C#
function openWindow(path)
{
    window.open(path,'','height=500,width=500');
}
Posted

1 solution

I tried running ur code its working fine.

 #039; is required coz it adds ' char at start and end of ur URL which is passed to JS function without which it won't work.

also u hve closed ur hyperlink tag twice

remove any 1 closing tag.

Tej Aj,
http://www.opexsoultion.com/forum

Fan Of:
http://www.abtstudioz.com
 
Share this answer
 
Comments
sujanir 15-Nov-10 17:12pm    
Thanks for the answer. The issue lies in the url that I pass and not in the javascript. The url that I pass is absolute url path & resides in one of the servers. This is a text file. IE does not recognise absolute url paths; it removes all forward slashes and therefore the page shows an error.

The work around that I have is to map the path to a local drive and use that instead.

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