Saravanakumar Sekaran

Saravanakumar Sekaran

  • 547
  • 2.3k
  • 187k

User Control not rendering in asp.net

Jul 22 2015 7:29 AM
I am dynamically rendering user control in aspx page. it not rendering evening though the data is binding
 
 
public static string LoadUserControl(string controlName)
{
using (Page page = new Page())
{
HtmlForm form = new HtmlForm();
UserControl userControl = (UserControl) page.LoadControl(controlName);
form.Controls.Add(userControl);
using (StringWriter writer = new StringWriter())
{
page.Controls.Add(form);
HttpContext.Current.Server.Execute(page, writer, false);
return writer.ToString();


}
}

Answers (3)