ASP.NET Rendering usercontrols with codebehind -


i want render usercontrol dynamicly code doesn't work expected. codebehind won't executed. here code rendering:

dim uccontrol usercontrol = loadcontrol(pcontrol.virtualpath & "/" & control & ".ascx")  dim ucsb new stringbuilder dim ucsw new stringwriter(ucsb) dim uchtml new htmltextwriter(ucsw)  uccontrol.rendercontrol(uchtml) 

thank help!

when rendering usercontorl normal lifecycle events not called. behavior design.

you cast usercontrol type , call methods explicitly:

dim uccontrol myusercontrol = ctype(loadcontrol(pcontrol.virtualpath & "/" & control & ".ascx"), myusercontrol)  uccontrol.page_load(me, eventargs.empty) 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -