Friday, 23 August 2013

Load a control in the main page from usercontrol

Load a control in the main page from usercontrol

I have a unique problem. I'm working on a .net solution where I do not
have access to the main aspx pages. Mainly, I cannot modify any of them.
I'm building a whole bunch of usercontrols, that will get used on various
.aspx page. I want to use the updatepanel, and one knows it requires the
scriptmanager control to be on the page.
So - what I do have access to is a placeholder on the .aspx page. What I
want to try and do is place the scriptmanager control in this placeholder.
I already know how to do this, by getting a reference to the context page
and then adding a control in there. However, I'm having an issue with the
timing. I have the updatepanel on the .ascx control, and I have the
scriptmanager load in the Page_PreLoad event of the control. This doesn't
seem to work, as it complains that "'The control with ID 'updUsers'
requires a ScriptManager on the page. The ScriptManager must appear before
any controls that need it.' Its obvious the updatepanel is loading before
the Page_Preload event.
Question is, exactly what method can I use to load the control? Can this
be done at all? Is there a better way to do this?

No comments:

Post a Comment