用__doPostBack(eventTarget, eventArgument)提交防止重复提交

来源:互联网 发布:浙江网络发票真伪查询 编辑:程序博客网 时间:2024/06/03 16:16
表达能力有限, 只供代码,自己体会
文件 Past.js 
  function CheckBox()
{
if(confirm('充值手机:['+document.MobileCommit.TextBox1.value+']   充值金额:[ '+document.MobileCommit.TextBox2.value+' ]  元  确认充值!')==false)
return false;
MobileCommit.Button1.disabled=true;   //禁止button1
MobileCommit.Button2.disabled=true;
__doPostBack('Button1','');    // 用__doPostBack提交
}

在页面文件Mobile.aspx 里加一个
<script src="js/Past.js" language="javascript"></script>

接下来是 Mobile.cs

private void Page_Load(object sender, System.EventArgs e)
{
     this.GetPostBackEventReference(this.Button1);
     Button1.Attributes.Add("onclick", "return CheckBox()");
}


你们可以照此方法测试