Call Javascript Function inside asp:Hyperlink Control
If you ever want to call a javascript function (with or without parameter) from a server side hyperlink control here it is..
Step 1 :
declare your javascript function between
Step 2:
<asp:HyperLink ID=”hypCate” runat=”server”
NavigateUrl=’<%# “javascript:showPopUp(” & DataBinder.Eval(Container.DataItem, “ID”) & “);” %>’
Text=’<%#DataBinder.Eval(Container.DataItem, “Name”)%>’ />
Carefully follow the single and double quotes for NavigateUrl attribute.
Needless to say showPopUp is the name of Javascript Function.
It displays the NAME as hyperlink. Clicking that calls javascript showPopUp.

How do you add single quotes around DataBinder.Eval(). I need to pass the value to my javascript function.
Scott Minor
February 11, 2008 at 4:43 pm
Above script on asp hyperling control has really helped me a lot.
Thanks.
arti
June 5, 2008 at 11:25 pm
Hi,
The above post is very helpful, it has helped me a lot.
Thanks,
Ujjwal B Soni
Ujjwal B Soni
September 13, 2008 at 12:51 am
Thanks mate, that helped a lot!!
Dean
January 6, 2009 at 8:37 am
Works! Thanks
Mindaugas
June 15, 2009 at 5:44 am
here is the c# version
just replace & with +
<asp:HyperLink Runat='server' ID='lnkFile'
NavigateUrl='’
Text=”>
M Ali
August 18, 2009 at 10:27 am
<asp:HyperLink Runat='server' ID='lnkFile'
NavigateUrl='’Text=”>
M Ali
August 18, 2009 at 10:28 am