Author: saburius | Posted on: 11/20/2009 12:48:25 PM | Views : 230

Hi, I have the following function to render a user conrol into a string replace token with UC). I'm not sure how if it works because I can't figure out how to call it in the pageload. I tried:
return RenderControl();
RenderControl();
Here is my code:
public string RenderControl(Control ctrl) { string controlpath = "~/pages/controls/page.ascx"; Control controltoload = this.LoadControl(controlpath); StringBuilder sb = new StringBuilder(); StringWriter tw = new StringWriter(sb); HtmlTextWriter hw = new HtmlTextWriter(tw); sb.Replace("[$uc:mycontrol$]", RenderControl(controltoload)); ctrl.RenderControl(hw); return sb.ToString(); }


...

Go to the complete details ...