472,121 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,121 software developers and data experts.

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 3726
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**********@yahoo.comI-WANT-NO-SPAMwrote in message
news:uF**************@TK2MSFTNGP06.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**@markNOSPAMrae.comwrote in message
news:uO**************@TK2MSFTNGP03.phx.gbl...
"senfo" <en**********@yahoo.comI-WANT-NO-SPAMwrote in message
news:uF**************@TK2MSFTNGP06.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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Ralph Freshour | last post: by
5 posts views Thread by terence.parker | last post: by
16 posts views Thread by Ben Sharvy | last post: by
2 posts views Thread by Srinivas | last post: by
6 posts views Thread by GD | last post: by
1 post views Thread by Chris | last post: by
reply views Thread by leo001 | last post: by

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.