// JScript 文件 function disableOtherSubmit() { var obj = event.srcElement; var objs = document.getElementsByTagName('INPUT'); for(var i=0; i<objs.length; i++) { if(objs[i].type.toLowerCase() == 'submit') { objs[i].disabled = true; } } } /// <summary> /// 防止按钮重复点击 /// </summary> public static void PreventDoubleSubmit(Button Button1,Page page) { PostBackOptions options = new PostBackOptions(Button1, string.Empty); StringBuilder sb = new StringBuilder(); if (Button1.CausesValidation && page.GetValidators(Button1.ValidationGroup).Count > 0) { options.ClientSubmit = true; options.PerformValidation = true; options.ValidationGroup = Button1.ValidationGroup; sb.Append("if (typeof(Page_ClientValidate) == 'function')"); sb.Append("if(Page_ClientValidate(/"" + Button1.ValidationGroup + "/")==false) return false;"); } if (!string.IsNullOrEmpty(Button1.PostBackUrl)) options.ActionUrl = HttpUtility.UrlPathEncode(Button1.ResolveClientUrl(Button1.PostBackUrl)); sb.Append("disableOtherSubmit();"); sb.Append(page.ClientScript.GetPostBackEventReference(options)); sb.Append(";"); Button1.Attributes.Add("onclick", sb.ToString()); }