ASP. NET to avoid repeated button clicks)

Source: Internet
Author: User

On csdn forums, some friends often ask questions about repeated Button clicking. I have also answered many times, but here I will explain the implementation method again to solve the problems of more friends. Due to my limited ability, what's wrong, please kindly advise.

First, add enableeventvalidation = "false" in <% @ Page %> ".

Btnok is the ID of the submit button. Add the callback method to the page_load event. btnok_click is the server to be implemented after submission.Code. The overall implementation process is relatively simple.

// Make the button unavailable and call back server events
Protected   Void Page_load ( Object Sender, eventargs E)
... {
This. Btnok. Attributes. Add ("Onclick", Clientscript. getpostbackeventreference (btnok,"Click")+ "; This. Disabled = true; this. value = 'submitting ...';");
}

// Button handling method (51aspx.com)
Protected   Void Btnok_click ( Object Sender, eventargs E)
... {
System. Threading. thread. Sleep (2000);
Clientscript. registerstartupscript (GetType (),"Btncommit","Alert ('submission successful !!! ');",True);
}

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.