我有一个用户控件。有什么方法可以获得usercontrol可用的页面吗?
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";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.