How can I get the parent page from a User Control in an ASP.NET Website (not Web Application) How can I get the parent page from a User Control in an ASP.NET Website (not Web Application) asp.net asp.net

How can I get the parent page from a User Control in an ASP.NET Website (not Web Application)


this.Page

or from just about anywhere:

Page page = HttpContext.Current.Handler as Page


I cannot think of any good reason for a user control to know anything about the page it is on as the user control should be ignorant of its context and behave predictably regardless of what page it is on.

That being said, you can use this.Page.


you can use the Parent property

if you need this to find a control on the page then you can use

Label lbl_Test = (Label)Parent.FindControl("lbl_Test");