How to get the page calling the usercontrol
I have a user control .Is there some way to get the p开发者_开发技巧age in which usercontrol is available ?
In your usercontrol write this method
protected void MyMethod()
{
Page myParent = this.Page;
...
}
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";
}
精彩评论