473,765 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disabling submit button until page is fully rendered with JavaScript?

Invoking a postback before a large ASP.NET page has fully rendered
will often cause the page to crash. This is unhelpful and confusing
to users.

I'm wondering if I can overcome this by disabling any controls that
invoke a postback until the page is fully rendered, ie setting the
controls disabled server-side, serving the page and then having a
JavaScript routine right at the bottom of the page re-enable them
client-side.

Has anyone tried this successfully?

Thanks,

ChrisN
Kew, Surrey
UK

Apr 4 '07 #1
3 3806
ChrisN wrote:
Invoking a postback before a large ASP.NET page has fully rendered
will often cause the page to crash. This is unhelpful and confusing
to users.

I'm wondering if I can overcome this by disabling any controls that
invoke a postback until the page is fully rendered, ie setting the
controls disabled server-side, serving the page and then having a
JavaScript routine right at the bottom of the page re-enable them
client-side.
I'm not positive on this, but it sounds like the JavaScript onload event
is what you're looking for. Basically, you'd load the page with the
button disabled, by default. According to the documentation the onload
event fires after the page finishes loading. If that's the case, you
would simply enable the button in your onload event handler.

http://www.w3schools.com/jsref/jsref_events.asp

Hope that helps,

--
Sean

website: http://senfo.blogspot.com
Apr 4 '07 #2
"senfo" <en**********@y ahoo.comI-WANT-NO-SPAMwrote in message
news:uF******** ******@TK2MSFTN GP06.phx.gbl...
I'm not positive on this, but it sounds like the JavaScript onload event
is what you're looking for. Basically, you'd load the page with the
button disabled, by default. According to the documentation the onload
event fires after the page finishes loading. If that's the case, you
would simply enable the button in your onload event handler.
That's certainly the way I do it...
Apr 4 '07 #3
I agree that the onload event is preferred.
In simple cases placing the JavaScript at the bottom of the page will work,
but for more complex pages things may not yet be fully initialized by that
point.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:uO******** ******@TK2MSFTN GP03.phx.gbl...
"senfo" <en**********@y ahoo.comI-WANT-NO-SPAMwrote in message
news:uF******** ******@TK2MSFTN GP06.phx.gbl...
>I'm not positive on this, but it sounds like the JavaScript onload event
is what you're looking for. Basically, you'd load the page with the
button disabled, by default. According to the documentation the onload
event fires after the page finishes loading. If that's the case, you
would simply enable the button in your onload event handler.

That's certainly the way I do it...
Apr 4 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14162
by: Paul Oakfleet | last post by:
The script below will disable Submit button until user accept terms, and will redirect user to another page after clicking on Submit button. The script seems to work fine on my PC (Windows XP, IE6), however I don't know if it's written well. I would like the opinion of someone who knows how to write these codes properly. Please let me know if there're any logic errors. PS: Please keep in mind that I didn't write this script, I found it
16
2060
by: Ralph Freshour | last post by:
How can I disable a button once it has been clicked? I want to prevent the user from clicking on it twice if they have a slow connection. Thanks...
5
33881
by: terence.parker | last post by:
I have a PHP application which I wrote last year - and the JavaScript worked fine then. For some reason, now it doesn't - neither on IE nor Firefox. Has something changed? When I click on my HTML link now (which executes a JS function), the firefox JS console tells me: Error: document.SubjectsForm.submit is not a function Any help would be much appreciated. Thanks!
16
9535
by: Ben Sharvy | last post by:
I want to get the user's choice of some menu items, and pass them to a (PHP) page in the URL, rather than with "Submit" button. I tried this, but it doesn't work: <a href="pagetwo.php?says=meaning"><img src="smiley.gif"></a> Pick one from drop-down menu: <p> <form> <select name=meaning>
2
1377
by: Srinivas | last post by:
Hi, I have a webform with some dropdown menus, textboxes required and custom validators. I added a click event handler for the button in which there is code for processing. This processing takes around one minute. I want to disable the button after the user clicks on it so that he cannot click it again while the processing is going on. But when I do this using javascript, the button is getting disabled while the form is not getting...
6
4050
by: GD | last post by:
Hi, I wonder how to disable the "submit" behavior of a button. What I want is to assign values to dynamically added user controls without page postback. Problem: dynamically created control can not be accessed because the button click trigers page postback(see sample code). When the button is clicked, an error occurs: "System.NullReferenceException: Object reference not set to an instance of an object." Please help. Thanks.
3
13104
by: Mark | last post by:
This is a solution... Often users want to keep clicking "submit" when they are waiting for server processing. Most apps these days like to disable the submit button to prevent this. You can't just disable the button in the OnClick event in ASP.Net because then the Click event won't post to the server (because you disabled it). I searched google groups, and there is a solution to this problem, but I didn't think it was clean enough and...
1
1930
by: Chris | last post by:
Can anyone recomend the best way of disabling a button a page until it is fully loaded? Would it need to be done with Javacript?
1
2250
by: arggg | last post by:
I created a submit form that calls a javascript:AjAX Command that will call the data and submit it without have the page refresh. This works perfect in Firefox however in IE and Opera when the submit button is pressed it just disables the button and does not submit the data. Any idea? <script type="text/javascript" src="<?=$config->getKey('Site_URL')."js/AJAX.js"?>"></script> <form name="EditUser" method="post" accept="text/plain"...
0
9568
marktang
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...
0
10007
jinu1996
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...
0
9835
tracyyun
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...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
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...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.