public static void MakeButtonSingleClick(System.Web.UI.WebControls.Button button, string buttonText)
{
System.Text.StringBuilder sbValid = new System.Text.StringBuilder();
sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sbValid.Append("if (Page_ClientValidate() == false) { return false; }} ");
sbValid.Append(string.Format("this.value = '{0}';", buttonText));
sbValid.Append("this.disabled = true;");
sbValid.Append(string.Format("document.all.{0}.disabled = true;", button.ClientID));
//GetPostBackEventReference obtains a reference to a client-side script function
//that causes the server to post back to the page.
sbValid.Append(button.Page.GetPostBackEventReference(button));
sbValid.Append(";");
button.Attributes.Add("onclick", sbValid.ToString());
}
private void Page_Load(object sender, System.EventArgs e)
{
...
ControlUtils.MakeButtonSingleClick(OrderPartButton, "Order in progress, please wait ...");
...
if (!Page.IsPostBack)
...
}