Hi all
Here is the best solution that I have come across for preventing double clicks...
1. Create a module, and call it GlobalModule.
2. Add the following method/function...
3. Every page that you need to prevent a double click, do the following.
3a. declare a global variable: dim pBackHandler as new GlobalModule
3b. add the following line into the page load method:
If the page has no validators, just set the variable PageHasValidators to false.
The question that I have now, is how can I throw up a javascript messagebox or confirmation dialog and use it?
Mike55.
Here is the best solution that I have come across for preventing double clicks...
1. Create a module, and call it GlobalModule.
2. Add the following method/function...
Code:
Public Sub ButtonClickEventGovenor(ByVal btn As System.Web.UI.WebControls.Button, ByVal PageHasValidators As Boolean)
Dim sJavaScript As String
If PageHasValidators Then
sJavaScript = "if (typeof(Page_ClientValidate) == function) {if (Page_ClientValidate())" & _
"{this.value=Please wait...;this.disabled = true;" & _
btn.Page.GetPostBackEventReference(btn) & ";}}"
Else
sJavaScript = "this.value=Please wait...;this.disabled = true;" & _
btn.Page.GetPostBackEventReference(btn)
End If
btn.Attributes.Add("onclick", sJavaScript)
End Sub
3. Every page that you need to prevent a double click, do the following.
3a. declare a global variable: dim pBackHandler as new GlobalModule
3b. add the following line into the page load method:
Code:
Call pBackHandler.ButtonClickEventGovenor(btnAdd, PageHasValidators:=True)
If the page has no validators, just set the variable PageHasValidators to false.
The question that I have now, is how can I throw up a javascript messagebox or confirmation dialog and use it?
Mike55.