Today, I have added new AjaxControlToolkit controls to Velodoc pages and I got exception “Extender controls may not be registered before PreRender” from running a page.
All our pages derive from our own WebPage class which derive from the standard Page class. WebPage provides features like custom error handling and QueryString parsing into page properties.
The page where we had the new extender control had the following method:
protected override void OnPreRender(EventArgs e)
{
//The following line is required, otherwise you get "Extender controls
//may not be registered before PreRender."
base.OnPreRender(e);
//Some code that displays errors on postbacks
...
}
The solution to the problem above is to add base.OnPreRender(e); at the beginning of the method.
9 comments:
Aha! Yours and the next few blogs that turn up when you google "Extender controls may not be registered before PreRender" were spot on. One thing to note: I didn't override OnPreRender() in the page that was throwing the error, so I thought I must have a different problem. Then I looked at our BasePage class (the base class for all our pages) and that's where it was happening!
Excellent work!Thanks a ton!
Thanks for sharing! Yours was the first link I tried and it solved my problem in a minutes. My lucky day!
To add a bit... I only had to add this to my application pages. The Master Pages not require it.
Regards,
-Jeff
Saved another couple of hours searching... Thanks a million!
I have included the code but still facing the error... what is the exact cause for this... No success yet.
thank U very much
provided solution not working doe me dude
When I got that error I almost pulled my hair out. I knew it had to do with the PreRender handler/method, but holy crap how annoying. Thanks!
Post a Comment