We do a test Web page, just need a button+ a label OK, through the button's background event to modify the label's Text property value to test the execution of the code in the background event
Front desk
Write a JS method:
<script type="text/javascript"> function myTest01 () { if (Confirm (" OK to continue?") ")) { returntrue; } return false ; } </script>
Button event:
Background
protected void Page_Load (object sender, EventArgs e) { btn_test. Attributes.Add ("onclick""return myTest01 ()" ); } protected void Btn_test_click (object sender, EventArgs e) { "1 "; }
The initial page value is as follows:
Click on the button to pop up the message, we click OK
Go Backstage, button event
The text of the label changes to Test1 after execution completes.
If you click Cancel, you do not enter the background button click event.
See blog: https://www.cnblogs.com/peterYong/p/6556565.html
The ASP. NET button executes the front and back method--the foreground pop-up prompt message, confirms the background method after confirming, cancels does not perform the background method