c# - Load a control in the main page from usercontrol -
i have unique problem. i'm working on .net solution not have access main aspx pages. mainly, cannot modify of them. i'm building whole bunch of usercontrols, used on various .aspx page. want use updatepanel, , 1 knows requires scriptmanager control on page.
so - have access placeholder on .aspx page. want try , place scriptmanager control in placeholder. know how this, getting reference context page , adding control in there. however, i'm having issue timing. have updatepanel on .ascx control, , have scriptmanager load in page_preload event of control. doesn't seem work, complains "'the control id 'updusers' requires scriptmanager on page. scriptmanager must appear before controls need it.' obvious updatepanel loading before page_preload event.
question is, method can use load control? can done @ all? there better way this?
edit:
i've tried events:
protected void page_preinit(object sender, eventargs e) protected override void oninit(eventargs e)
details
just clarify, usercontrol code looks like:
public partial class pollmodule : modulebase { protected override void oninit(eventargs e) { page page = httpcontext.current.handler page; page.init += delegate(object sender, eventargs e_init) { if (scriptmanager.getcurrent(page) == null) { scriptmanager smgr = new scriptmanager(); page.form.controls.addat(0, smgr); } }; base.oninit(e); } protected void page_load(object sender, eventargs e) { } }
somewhat working edit
i able partially working attaching updatepanel init, know way adding scriptmanager working, guess missing right page event attach to.
if it's simple matter of using scriptmanager in usercontrol - can use scriptmanagerproxy instead.
this way ajax controls compile , run , there won't conflict main page's scriptmanager
just declare in control markup, e.g.
<%@ control language="csharp" autoeventwireup="false" codefile="mycontrol.cs" inherits="mycontrol" %> <asp:scriptmanagerproxy id="scriptmanagerproxy1" runat="server"> <services> </services> <scripts> </scripts> </asp:scriptmanagerproxy>
Comments
Post a Comment