Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HTML
Hello Friends,
I Have Problem With adding handker in Javascript.

I want to add handler for Hyperlink asp.net control in Javascript.
My Hyperlink Button is dynamically created control. 
please Help Me,
Thanks,,
Posted

1 solution

add on page_init event of page
C#
protected void Page_Init(object sender, EventArgs e)
{
 linkTest.Attributes["onclick"] = "Show();";
 Page.Form.Controls.Add(linkTest);
}


javascript method

XML
<script type="text/javascript">
       function Show() {
           alert("Clicked");
       }
   </script>


Hope this will help you
 
Share this answer
 
Comments
prashant patil 4987 27-Aug-12 4:54am    
what is "linkTest"? is It Hyperlnk Button which is dynamically created.? my problem is that, i don't know how many hyperlink button are created dynamically.. i want all hyperlink button hndlerin java script?
SinghPrateek 27-Aug-12 5:03am    
Are you using LinkButton or HyperLink?
If controls are dynamic still you to have initialize and push the control into the page or any container, at that time set the onclick property of the control,
prashant patil 4987 30-Aug-12 4:13am    
yes m using LinkButton. and i had get linkbutton id also but not set event handler.
SinghPrateek 30-Aug-12 15:32pm    
put your code, than we could be in better position to help you

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