[英]How to get the page calling the usercontrol
我有一个用户控件。有什么方法可以获得usercontrol可用的页面吗?
在您的usercontrol中编写此方法
protected void MyMethod()
{
Page myParent = this.Page;
...
}
你想要Page
属性。
如果您需要回写某个类型的页面,则必须进行转换:
var myUserPage = Page as MyCustomUserPageClass;
if (myUserPage != null) {
myUserPage.Foo = "bar";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.