Hmmm, what's the point of a *server* side button that does nothing but execute code at the *client*? In that case, why not just an plain ol' HTML button? (input type="button")
An HtmlInputButton will end up as a "input type="submit" button in the browser, so the form gets submitted when you click it. Just as with plain HTML buttons, you can add some code that fires when you click the button. You can use the Attributes collection of the button to add some code to the click handler:
Code:
myDeleteButton.Attributes.Add("onclick", "return(confirm('Are you sure you want to delete this item?'));");
This code will stop the form from being submitted when the user presses the cancel button.
You can use the same technique to call JavaScript functions embedded in the page or in a separate .
js file:
Code:
myOtherButton.Attributes.Add("onclick", "return MyJSFunction();");
If you make sure that MyJSFunction returns false, the page will never be submitted to the server, and the button is pure client side.
However, I think this stuff is more confusing than useful. If you do only need a client side button, use a simple HTML button.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.