views:

38

answers:

2

I have a user control .Is there some way to get the page in which usercontrol is available ?

+1  A: 

You want the Page property.

If you need to write back to a page of a certain type, you'll have to cast:

var myUserPage = Page as MyCustomUserPageClass;
if (myUserPage != null) {
  myUserPage.Foo = "bar";
}
Dave Markle
A: 

In your usercontrol write this method

protected void MyMethod()
{
    Page myParent = this.Page;

    ... 
}

alt text

Pranay Rana
Best to use MyPage page = this.Parent as MyPage; in case the Page type isn't MyPage.
Ocelot20