Hi all.
I have a problem in my website in trying to prevent a user from double submitting the form. I am calling a subroutine from my page_load event that passes in the commandbutton that I want to prevent users from being able to click twice. Everything is working great, except for one small detail. When my client-side validation fires, and is invalid, I see the red text that displays the error message, but the problem is that something is "stuck" and I cannot cause a postback for 1 click.. I will give 2 examples of what I mean by this:
1) I press submit and my client-side validation tells me that I need to enter the password, but at this point, I click the cancel button, which should take me to a previous screen, but instead, all it does is get rid of the validation text that tells me to enter the password. When I click cancel AGAIN, it works great.. Basically I have to press cancel twice in this case.
2) This is the real problem I have had with this: After validating a dropdown, the validation errormsg says I need to select a value from the dropdown before submitting. OK, I do this, on a dropdown that has autopostback=tr ue set, but IT DOES NOT POSTBACK. This is very bad because I have logic on the onselectedindex change event for this dropdown, and it now doesn't fire. Of course, if I re-select another dropdown value at this time, then everything is great, and it postsback just fine.
I hope the code below will be enough information to duplicate, and/or help me determine what I am doing wrong. I can also dumb the code down if need be, so that it only disables the submit button for example. Also, if need be, I can post a small sample asp.net application later that may help you to see the problem.
Here is the code:
Public Sub PreventDoubleSu bmit(ByRef cmd As System.Web.UI.W ebControls.Butt on)
Dim sb As New System.Text.Str ingBuilder
ClientScript.Ge tPostBackClient Hyperlink(cmd, "")
sb.Append("if (typeof(Page_Cl ientValidate) == 'function') { ")
sb.Append("if (Page_ClientVal idate() == false) { return false; }} ")
sb.Append("scro ll(0,0);")
sb.Append("var outerPane = document.getEle mentById('Freez ePane');")
sb.Append("var innerPane = document.getEle mentById('Inner FreezePane');")
sb.Append("if (outerPane) outerPane.class Name = 'FreezePaneOn'; ")
sb.Append("if (innerPane) innerPane.inner HTML = 'Please wait...';")
cmd.Attributes( "onclick") = sb.ToString()
End Sub
It is called from page_load as follows:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
PreventDoubleSu bmit(Me.cmdSend )
End Sub
there is also a couple divs in the html that are needed and referenced by the javascript to basically pop up a 'Please wait' message on successful validation and submit:
<div align="center" id="FreezePane " class="FreezePa neOff">
<div id="InnerFreeze Pane" class="InnerFre ezePane"> </div>
</div>
Finally, here are a few css styles to make it look nice:
.FreezePaneOff {
visibility: hidden;
display: none;
position: absolute;
top: -100px;
left: -100px;
}
.FreezePaneOn {
position: absolute;
top: 0px;
left: 0px;
visibility: visible;
display: block;
width: 100%;
height: 100%;
background-color: #666;
z-index: 999;
filter:alpha(op acity=85);
-moz-opacity:0.85;
padding-top: 20%;
}
.InnerFreezePan e {
text-align: center;
width: 66%;
background-color: #efefef;
color: black;
font-size: large;
border: dashed 2px #111;
padding: 9px;
}
0 6187 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: entoone |
last post by:
I have an html form, that has fields and when the submit button is pressed,
the information is transferred to a php file. Which then inserts the data
into my sql database. How can I go about ensuring that someone isn't able to
submit thier information twice, or to somehow have the database checked
before inserting the information, to see if it's there already. I have some
duplicates happening and would like to stop it.
|
by: G4Gun |
last post by:
Hi,
I have a form in which I have this link :- <
href="javascript:submitform(parameters );"> . In the JavaScript
function submitform, there is the code for submitting the form.Thi
works fine with single click on both IE,NN6.In IE the form is submitte
only once even for double click.But if you double click on the link i
NN6, the form is submitted twice. This causes problem. The workaroun
for this was that we set a flag(indicating form...
|
by: anonieko |
last post by:
Scenario: You have a page that is TOO slow to refresh.
But it allows partial flushing of html contents. I.e.
Submit button already appears but you don't
want your users to click on it prematurely
because other parts are still coming.
Here I put a javascript the will enable only
submit button only after 5 seconds after the page
is load fully.
|
by: Lloyd Dupont |
last post by:
I have a web form with multiple part.
I do want the user to click the submit button to post back, so I know which
functionality was triggered.
unfortunately, when the focus is any text box, if the user hit ENTER the
form is submitted, how could prevent that ?
thanks, ...
Lloyd
|
by: Anders K. Jacobsen [DK] |
last post by:
Hi im building a administraive application (primary) CRUD.
But how do i prevent users not to double click on eg a insert button? I
would be great the have uniform way to deal with this since I have a LOT of
buttons. So adding javascript manually to each page does not sound
compeling. I wouldnt mind if the soultion was serverside since it after all
is rare they do double click.
Thanks in regards
Anders
| |
by: rmgalante |
last post by:
I have written an ASP.Net application that uses the standard
client-side and server-side validation for various fields on the form.
Some of the customers that use the form report symptoms that appear to
be the result of double-clicking the submit button on the form.
The form has three ASP:Button tags, each of which gets translated into
INPUT TYPE="SUBMIT" HTML elements. One submits the form's data. One
logs the user out. And the other...
|
by: Ed Jay |
last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call:
function chkNum(cellname) {
var str = document.getElementById(cellname).value.toString(10);
if (str < 28 || str > 36) {alert("Temperature entered is out of range.");
return;}
}
I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
|
by: APA |
last post by:
Why does adding code to the form submit function using the RegisterOnSubmitStatement method prevent the server side event handler for the submit
button from firing? This is completely useless. I need some custom javascript validation on form submit but why does is kill the submit button event
handler? Submit buttons don't use __doPostBack so what is being effected?
|
by: PJ6 |
last post by:
Is there a way to prevent the double-click event on an element from causing
IE6 to select everything? Cancelling the event doesn't work.
Paul
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |