Disabling repeated submission during Ajax return

Source: Internet
Author: User

Recently encountered a problem: the page uses Ajax, not jquery, and uses Microsoft scriptmanager and updateprogress. How does one prohibit repeated submission during data return? That is, after you click the submit button, the button cannot be used. After the data is returned, the button status automatically becomes available!

I went to the Microsoft forum to ask, and the experts gave the answer. After testing, the following method is feasible!

Front-end page:

<Form ID = "form1" runat = "server">
<Asp: scriptmanager id = "scriptmanager1" runat = "server"/>
<Asp: updatepanel runat = "server" id = "updatepanel1">
<Contenttemplate>

<Asp: button text = "Submit" id = "btn_go" runat = "server" onclick = "btn_go_click"/>
</Contenttemplate>

</ASP: updatepanel>
<Asp: updateprogress id = "updateprogress1" runat = "server" associatedupdatepanelid = "updatepanel1">
<Progresstemplate>
processing ......
</Progresstemplate>
</ASP: updateprogress>
</Form>

Background code:

Protected void page_load (Object sender, eventargs E)
{
Scriptmanager. registeronsubmitstatement (page, typeof (PAGE), "go_disabled", "document. getelementbyid ('btn _ go '). Disabled = 'Disabled ';");
Scriptmanager. registerstartupscript (page, typeof (PAGE), "clear_disabled", "document. getelementbyid ('btn _ go'). Disabled =''; ", true );

}
Protected void btn_go_click (Object sender, eventargs E)
{
System. Threading. thread. Sleep (3000); // simulate a task
// For (long I = 1; I <1000000000; I ++ );
Btn_go.text = "execute complete ";
}

 

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.