客户端:
<asp:Button ID="btnSubmit" runat="server" Text="提 交" class="btn2" OnClick="btnSubmit_Click"
OnClientClick="this.disabled=true;" UseSubmitBehavior="false"/>
在服务器端:
if(something error before insert to database){
Response.Write("error");
this.btnSubmit.Enabled = true;//解除锁定
}
else{
SubmitToDB();
}
Response.Write("error");
this.btnSubmit.Enabled = true;//解除锁定
}
else{
SubmitToDB();
}
关键点:UseSubmitBehavior