2014年5月13日 星期二

ASP.NET防止等待回應中重複按Submit

ASP.NET防止等待回應中重複按Submit

Submit送出時改變Button Enable狀態,讓使用者無法再按Submit

HTML:
  1. <asp:button id="btnSubmit" onclick="btnSubmit_Click" runat="server" text="Submit" usesubmitbehavior="false" width="100px">
  2. </asp:button>

C#:
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. this.btnSubmit.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btnSubmit, "click") + ";this.disabled=true; this.value='Saveing...';");
  4. }

沒有留言:

張貼留言