Author: sagachoo | Posted on: 6/24/2010 6:11:10 PM | Views : 264

I'm trying to get rendered content from a usercontrol which works fine but only the mark up get rendered but all the events like Page_Load of the usercontrol doesn't get called. here is my code

Page P= new Page(); MyUserControl UC = (MyUserControl)P.LoadControl("~/library/usercontrols/MyUserControl.ascx"); UC.ID = "MyId"; StringBuilder SB= new StringBuilder(); using (StringWriter SW= new StringWriter(SB)) { using (HtmlTextWriter HT= new HtmlTextWriter(SW)) { UC.RenderControl(HT); } } string Content = SB.ToString();
...

Go to the complete details ...