code_junkie

Is there a way to load a usercontrol if you don't have access to Page

Nov 13th, 2011
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. Page.LoadControl("~/controls/MyControl.ascx");
  2.  
  3. Page currentPage = HttpContext.Current.Handler as Page;
  4. if (currentPage != null)
  5. {
  6. currentPage.Controls.Add(
  7. currentPage.LoadControl("~/controls/MyControl.ascx"));
  8. }
Add Comment
Please, Sign In to add comment