如何在母版页上设置子页面控件属性? [英] How to set Child Page control Property on master page?

查看:161
本文介绍了如何在母版页上设置子页面控件属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







在我的母版页面当我点击这个菜单时我有一个菜单条我要设置

Panel1.visible = true但是此面板位于子页面上的默认页面上。



如何设置此属性。 />


感谢....

解决方案

OnClick 使用 this.Page 与您的菜单项相关联的事件您可以访问当前网页,而不是您可以测试是否是您的默认页面并转换为它并且您将有权访问其公共属性和方法,如下所示:

  if  this  .Page   DefaultPage) //  这里必须是你的默认页面类的名称! 
{
DefaultPage myPage =(DefaultPage)。第;
myPage.Panel1.Visible = true ;
}


您可以将Panel1作为属性从子页面公开,然后使用此属性根据需要设置可见性。

Hi,


In My Master Page There is one menu strip when i click on this menuitem i want to set
the Panel1.visible=true but this panel is on the Default page means on the child page .

How can set this property.

Thank's....

解决方案

In OnClick event associated with you menu item by using this.Page you will have access to the current web page, than you could test if is your default page and convert to it and you will have access to its public properties and methods like below:

if( this.Page is DefaultPage)   //Here must be the name of your "Default Page" class!
{
    DefaultPage myPage = (DefaultPage)this.Page;
    myPage.Panel1.Visible = true;
}


You can expose Panel1 as a property from your child page then use this property to set the visibility as per your need.


这篇关于如何在母版页上设置子页面控件属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆