This sample code uses 4 variations;
- TestButton1 - a standard html input type 'button', which submits the page using hand coded js
- TestButton2 - a standard html input type 'submit', it has the default behaviour of submitting the form
- TestButton3 - an asp:button with the OnClientClick (rendered as onclick) declared in the mark up
- TestButton4 - an asp:button with the onclick defined in the code behind or c#
The c# 'code-behind'
if you do not include the return statement in the onclick the form will post back regardless of which button is clicked 'Ok' or 'Cancel'; for instance you do NOT want to do this
onclick="AreYouSure();"but instead do this