Skip navigation.

Gordon Segal's Advice to An EntrepreneurAll recent postsCancelling Event Bubble Interferes With MS AJAX On Postback

Extender/Script controls may not be registered before PreRender

If you receive an error similar to this, it’s time to look for a missing call to base.OnPreRender.

If you override OnPreRender(EventArgs e) in a custom control, the conventional wisdom says you need to remember to call base.OnPreRender(e). Recently, I ran into this issue and found out the hard way that the page which hosts your control also must call base.OnPreRender in its OnPreRender (if you override it at all).

I hope I saved someone an hour or two of debugging. Thanks to Daniel Balla for pointing me in the right direction.

Comments

Comment permalink 1 Shree Menon |
Yes you did -- Thanks a lot....
Comment permalink 2 Willie Brits |
Thanks you did save me an hour or two
Comment permalink 3 Christoph |
Thanks. You did indeed save me some time.
Comment permalink 4 Chris N |
I'll add to the comments here... yes, that did save a lot of time and a lot of head-desk action...

Thanks!
Comment permalink 5 Pankaj Mittal |
Cool.. thanks.
Comment permalink 6 Stephanie |
Thank you for posting this.
Comment permalink 7 sunfly |
Could you help me ? I make a custom control which have a ScriptManager and a CalendarExtender .They were defined in the CreateChildControls.I didnot override OnPreRender. But I still had this
error(Extender controls may not be registered before PreRender.).
What's wrong?
I am sorry.I am a chinese.My english is bad.
Thanks.
Comment permalink 8 Irshaad |
sunfly,
have you managed to fix your problem?
I have the same problem and need a solution.
Comment permalink 9 surya |
Hi Milan,
I didnt override the prerender event but i do get the same error, can u guess the source of error,
I am using Calendar Extender Control in .ascx & while implementing this in a sharepoint site i get this error.

thanks ,
Surya
Comment permalink 10 Milan Negovan |
Unfortunately, I can't guess the source of error. Perhaps, overriding OnPreRender would be a good idea. :)
Comment permalink 11 Surya |
Milan,
Thanks, I did tried your suggestion, thing is that i am not using Prerender event in my Usercontrols altogether. So there might be something i have left out.. Will try & find the cause & Share things with you.

Also it works fine in Few usercontrols & shows up such error in other user controls

thanks for ur time...

Surya
Comment permalink 12 Ivan |
Thanks to you and Daniel Balla ;)
Comment permalink 13 Sean |
Thanks Milan,
My user control started showing this error when I moved it onto an UpdatePanel. I got it working after I removed a 'using statement' referencing 'Page' during the 'OnLoad()' event, e.g.:

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    Page parentPage = this.Page as Page;
    using (parentPage)
    {
    }
}

The using statement wasn't a good idea in the first place but I'd like to know what it was doing to page to cause the error.

Sean.
Comment permalink 14 Dylan Baxter |
Yep, you saved me quite the headache! Thank you!
Comment permalink 15 John Gilmore |
Yes, you saved me alot of debug time! Thanks!

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

TrackBacks

Sorry, TrackBacks are not allowed.

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):