08.19.09

Javascript: To prevent or disable double click of button

Posted in Uncategorized tagged , , at 9:18 am by aspnet

Dim sb As New System.Text.StringBuilder()
sb.Append(“if (typeof(Page_ClientValidate) == ‘function’) { “)
sb.Append(“if (Page_ClientValidate() == false) { return false; }} “)
sb.Append(“this.value = ‘Please Wait…’;”)
sb.Append(“this.disabled = true;”)
sb.Append(Me.Page.GetPostBackEventReference(Me.btnSubmit))
sb.Append(“;”)
btnSubmit.Attributes.Add(“onclick”, sb.ToString())

1 Comment »

  1. Sayee Ahmed said,

    thank you very much for your post , its save my day . I have extended your script .

    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append(“if (typeof(Page_ClientValidate) == ‘function’) { “);
    sb.Append(“if (Page_ClientValidate() == false) { return false; }} “);
    sb.Append(“this.value = ‘Please Wait…’;”);
    sb.Append(“this.disabled = true;”);
    sb.Append(Page.GetPostBackEventReference(this.btnSaveTransaction));
    sb.Append(“;”);

    btnSaveTransaction.Attributes.Add(“onclick”, “javascript:if(confirm(‘Do you want to save this record?’)== false) return false;” + sb.ToString());


Leave a Comment