Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Just as the subject asks.

EDIT 1

Maybe it's possible sometime while the request is being processed to store a reference to the parent page in the user control?

like image 479
JoeB Avatar asked Jun 22 '09 19:06

JoeB


People also ask

How do you call the parent page method in user control?

Use event and delegate concept make delegate as same signature as your method in parent page and then assign parent methad to it in parent page load event then call this delegate through event in user control. code sample and link is given below. Show activity on this post.

How do you access the hidden field of the parent page in the user control?

Answers. In your user control code behind (C#) you can use... HiddenField hf = (HiddenField)Parent.


1 Answers

this.Page 

or from just about anywhere:

Page page = HttpContext.Current.Handler as Page 
like image 173
Paul Alexander Avatar answered Sep 18 '22 11:09

Paul Alexander