Monday, May 12, 2008

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:

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.

No comments: