Disabling submit button until page is fully rendered with JavaScript?

C

ChrisN

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
 
S

senfo

ChrisN said:
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,
 
M

Mark Rae

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

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,833
Latest member
BettyeMacf

Latest Threads

Top