Avoiding Button Double Click (DropDownList)
-
private void checkButtonDoubleClick(Button button)
{
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(this.Page.ClientScript.GetPostBackEventReference(button, ""));
sbValid.Append(";");
button.Attributes.Add("onclick", sbValid.ToString());
}the above coding avoid double click for an button.. also the same i would like to apply for an dropdownlist. because according to the selection of dropdown value, i m changing the button textvalue. according to the text value i m calling different functions.so when user select the dropdownlist item, it take some time. during that time, user should not click the button obviously. so i want to disable the button while user selecting item from dropdownlist until the text changes. how to achieve it? help me - KARAN
-
private void checkButtonDoubleClick(Button button)
{
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(this.Page.ClientScript.GetPostBackEventReference(button, ""));
sbValid.Append(";");
button.Attributes.Add("onclick", sbValid.ToString());
}the above coding avoid double click for an button.. also the same i would like to apply for an dropdownlist. because according to the selection of dropdown value, i m changing the button textvalue. according to the text value i m calling different functions.so when user select the dropdownlist item, it take some time. during that time, user should not click the button obviously. so i want to disable the button while user selecting item from dropdownlist until the text changes. how to achieve it? help me - KARAN
Karan_TN wrote:
so i want to disable the button while user selecting item from dropdownlist until the text changes.
If doing all the stuff client side then: Attach a javascript function to Dropdownlist items or to Dropdown change event. In that JS function, just disable the button. Once you are ready with all the stuff, enable it back (like while calling different function) If doing all the stuff server side then: In selectedindex change event, disable the button. After you have worked on other functions, at the end enable the button.