What is the best way to determine which ASP.NET button was clicked on a single page using JavaScript?
+1
A:
You can easily add a client side Javascript click handler to an ASP button like this.
Button1.Attributes.Add("onclick", "alert('You clicked me!');");
Craig
2008-12-18 22:56:12
Thanks for the answer +1....
Michael Kniskern
2008-12-18 23:16:32
+4
A:
Add a client-side onclick handler to each button pointing to the same function?
e.g.
<button onclick="myHandler(this.ID)" />
Robert C. Barth
2008-12-18 22:56:51
+2
A:
I just the set the OnClientClick event handler for the button with the JavaScript function I wanted executed when the button was clicked during the Page_Load event.
protected void Page_Load(object sender, EventsArgs e)
{
MyButton.OnClientClick = "MyJavaScriptMethod();";
}
Michael Kniskern
2008-12-18 23:15:46