Reputation:
I have a user control .Is there some way to get the page in which usercontrol is available ?
Upvotes: 1
Views: 557
Reputation: 176956
In your usercontrol write this method
protected void MyMethod()
{
Page myParent = this.Page;
...
}
Upvotes: 3
Reputation: 97821
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";
}
Upvotes: 1