OnclientclickIt is a client-side event processing method. It generally uses JavaScript for processing, that is, it runs directly on the IE end and runs at a click.
Onclick is the server-side event processing method. It runs on the server, that is, IIS. After you click it, execute PostBack before running it.
Onclientclick is often used for client detection. Of course, it can also be detected on the server side, but it requires interaction with the server, consuming resources and poor user experience.
When a widget has both onclick and onclientclick,OnclientclickBeforeOnclickRun
The correct statement should be:
< ASP: button ID = "Btnsave" Runat = "Server" Text = "Save" Onclick = "Btnsave_click" Onclientclick = "Return savefunc ();" />
Savefunc verifies the data. When the verification passes and returns true, the server-side method is saved. If the verification fails, false is returned, and the server-side saving method is not executed.
Incorrect syntax:
Code
<! -- Whether the verification is successful or not, the server-side method is executed and cannot be used for verification. -->
< ASP: button ID = "Btnsave" Runat = "Server" Text = "Save" Onclick = "Btnsave_click" Onclientclick = "Savefunc ();" />
returns false regardless of the verification result, the server-side method will never be executed -->
Asp: button id =" btnsave " runat =" server " text =" save " onclick =" btnsave_click " onclientclick =" savefunc (); Return false; " />