用ajax啦,用这个方法也可以!
/// <summary>
/// 防止重复提交按钮
/// </summary>
/// <param name="page">this</param>
/// <param name="Button">按钮控制名称</param>
/// <param name="Btn">按钮控制名称string</param>
/// <param name="BtnValue">等待信息</param>
/// <asp:Button ID="btnSave" runat="server" CssClass="btn1" Text="保 存" OnClick="btnSave_Click" OnClientClick="if(confirm('确定保存吗?')){this.value='数据提交中……';this.disabled=true;}else {return false ;}" UseSubmitBehavior="False" />
public static void AjaxButton(Page page, System.Web.UI.WebControls.Button Button, string Btn, string BtnValue)
{
Button.Attributes.Add("onclick", "state=true;");
StringBuilder sb = new StringBuilder();
sb.Append("if (!state) return;");
sb.Append("var button=document.getElementById('" + Btn + "');");
sb.Append("button.value='" + BtnValue + "';");
sb.Append("document.body.style.cursor='wait';");
sb.Append("button.disabled=true;");
string strScript = "<script>";
strScript = strScript + "var state=false;";
strScript = strScript + "window.attachEvent('onbeforeunload',function(){" + sb.ToString() + "});";
strScript = strScript + "</" + "script>";
page.ClientScript.RegisterStartupScript(page.GetType(), "onbeforeunload", strScript, false);
}