How to: Respond to Button Web Server Control Events in Client Script
To add client script, which handles the OnClientClick event, to a button Web server control
In the ASP.NET button Web server control to which you want to add client script (a Button, LinkButton, or ImageButton control), set the OnClientClick property to the client script that you want to run.
If you want to be able to cancel the submission, set the OnClientClick property to the string "Return" and the function name. The client script can then cancel the submission by returning false.
The following code example shows how to add a client-script click event to a Button control.
<%@ Page Language="C#" %> <script runat="server"> void Button1_Click(Object sender, EventArgs e) Label1.Text = "Server click handler called."; End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <body> <form id="form1" runat="server"> <asp:Button ID="Button1" Runat="server" OnClick="Button1_Click" OnClientClick="return confirm('Ready to submit.')" Text="Test Client Click" /> <br /> <asp:Label ID="Label1" Runat="server" text="" /> </form> </body> </html>