ASP.NET防止页面重复提交

页面提交时,由于处理时间可能较长,用户反复点击按钮提交可能造成意外结果。

防止按钮重复提交

在page_load中对按钮注册如下代码:

this.Button2.Attributes["onclick"] = this.Page.ClientScript.GetPostBackEventReference(this.Button2,"") + ";this.disabled=true;"; //Button2为按钮ID
页面提交之后将按钮置为不可用,处理完成后恢复可用状态。

posted @ 2009-12-14 16:54  部落格  阅读(207)  评论(0编辑  收藏  举报