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

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.