Monday, May 21, 2007

To change button text as "page loading" once button is clicked :)

Execute the below code in page_load event


_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("this.value = 'Please wait...';");
sbValid.Append("this.disabled = true;");
sbValid.Append("document.all.btnSubmit.disabled = true;");
//GetPostBackEventReference obtains a reference to a client-side script function that causes the server to post back to the page.
sbValid.Append(this.Page.GetPostBackEventReference(this.btnSubmit));
sbValid.Append(";");
_this.btnSubmit.Attributes.Add("onclick", sbValid.ToString());

Where btnSubmit is a simple asp button

No comments: