Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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...

   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:

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.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...