开发者

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;

    ... 
}

How to get the page calling the usercontrol


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";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜