日期:2014-05-18 浏览次数:20658 次
protected void Page_Load(object sender, EventArgs e)
{
PostBackOptions options = new PostBackOptions(Button1,string.Empty);
StringBuilder sb = new StringBuilder();
if (Button1.CausesValidation && this.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("this.disabled = true;");
sb.Append(ClientScript.GetPostBackEventReference(options));
sb.Append(";");
Button1.Attributes.Add("onclick", sb.ToString());
}