Disabling submit button until page is fully rendered with JavaScript?

  • Thread starter Thread starter ChrisN
  • Start date Start date
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
 
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,
 
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...
 
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.
 
Back
Top