/ Published in: C#

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static class UserControlHelper { public static HtmlString RenderControl<T>(this HtmlHelper helper, string controlPath) where T : UserControl { return RenderControl<T>(helper, controlPath, null); } public static HtmlString RenderControl<T>(this HtmlHelper helper, string controlPath, Action<T> action) where T : UserControl { T controlToRender = (T)pageHolder.LoadControl(controlPath); pageHolder.Controls.Add(controlToRender); if (action != null) action(controlToRender); { HttpContext.Current.Server.Execute(pageHolder, sw, false); } } }
Comments
