Last post Feb 06, 2009 03:38 AM by firstname.lastname@example.org
Jun 03, 2008 05:20 PM|Ananth.kvs|LINK
"An extender can't be in a different UpdatePanel than the control it extends" exception is thrown when I try to add a hovermenuextender from a server control.
I've created a server control which would construct hovermenuextender control dynamically and add it to the page. when I try to add the hovermenuextender to the page controls, above exception is thrown.
The server control inherits Control class.
When a dynamic server control which contains a extender control is added to a page, which has an updatepanel, would the framework try to surround the extender control with an updatepanel before adding it to the page?
I searched the web to find a solution. I am not able to find one that solves my problem.
Can anyone help me?
Jun 03, 2008 06:50 PM|vgiambattista|LINK
It sounds like you need to add your hovermenuextender control to the same update panel that contains the page element you are extending. You can do it with code like this:
I'm guessing that you have a property on your server control that specifies the control you want to extend. You could add an optional property for the update panel, also.
Jun 05, 2008 09:32 PM|Ananth.kvs|LINK
Thanks for your reply.
I tried capturing the parent update panel that is present in the page and tried adding the hovermenu control constructed dynamically. Still I am getting an error. Now, its different kind of exception
"Extender controls may not be registered after PreRender".
I think after the page prerender event, its not able to add the extender from web server control. I may be wrong too.
Jun 05, 2008 09:44 PM|vgiambattista|LINK
Are you sure it says "after" rather than "before"? Are you doing anything interesting like caching your control in the session, or are you creating a new hover extender every time?
Jun 06, 2008 01:37 PM|Ananth.kvs|LINK
Yeah. It says "after". In my application, there are 4 button controls which would be disabled for some reason. I am constructing hoverextender, to display the reason why it's disabled, if the button is disabled for each of them. The thing is it's failing
for the very first time. I think I am missing something.
Jun 06, 2008 03:15 PM|vgiambattista|LINK
Is the exception being thrown by the hoverextender, or from somewhere else?
If it's from the hoverextender, then I think you can try this technique to try to get around it:
You'll be overriding the OnPreRender method, and adding your extender to the DOM there. The link is for dealing with a "before" message, but it's worth trying anyways. It suggests calling the base OnPreRender method before you add your extender control
to the DOM. If that doesn't work, you can try doing it the other way: calling the base PreRender after you add your code.
I do remember running into something similar before, and I think I just kept moving my code from LifeCycle event to LifeCycle event until I found a location that worked -- but I don't remember what finally helped, I'm afraid. If you download the source
code for the Toolkit and look through there, you might be able to do a text search in the hover extender and figure out where the exception is being thrown. This might help you to diagnose the problem. In any case, from everything I've seen, this has to
do with the way the Toolkit is implemented, rather than with ASP.NET itself.
Jun 11, 2008 09:48 PM|Ananth.kvs|LINK
http://forums.asp.net/t/1061827.aspx helped me to solve my problem.
Feb 06, 2009 03:38 AMemail@example.com|LINK
Code worked great for me