母版页问题 [英] Master Page problems

查看:61
本文介绍了母版页问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们请帮助我

我有一个带有默认"页面的母版页面.
在母版页上有六个按钮.我想在页面上看不到按钮4.
所以我该如何做这项工作,请帮助我,并给我一些文章..

我想知道这个解决方案的朋友,请再次帮助我......... faiz

Hi friends please help me

i have a master page with Default page.
there are six buttons on master page.i want to invisible button 4 on the page .
so how i can do this work please help me and give me some articles ..

i want to know this solutions friends please help me again ......faiz

推荐答案

将此代码与您自己的按钮ID一起使用

Use this code with your own button id

(this.Page.Master.FindControl("btnRegister") as Button).Visible=false;


try:
try:
Button myButton = (Button) Master.FindControl("buttonId");
if(myButton != null)
{
    myButton .Visible =false;
}


最好的方法是在母版页上拥有一个公共属性.此属性可以更改控件的可见性,并且您可以有条件地从子页面使用此属性.

参见以下示例:
在我的母版页中有(RightSide 是我的母版页中的面板的名称)

The best way to do this would be to have a public property on the master page. this property can change the visibility of the controls and you can use this property from child pages conditionally.

see this example:
in my master page i have (RightSide is name of a Panel in my master page)

   public bool SidePaneVisibility
   {
   get
   {
    return RightSide.Visible;
   }
   set
   {
      RightSide.Visible = value;
   }
}


而且我在内容页面上有条件地使用它:


and I am using it from my content page conditionally as:

if (Session["UserId"] == null)
          {
              MasterPage master = (MasterPage)this.Master;
              master.SidePaneVisibility = false;
          }


这篇关于母版页问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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