如何隐藏内容页面中的Masters html按钮(没有id)? [英] how to hide Masters html button(which is having no id) in content page?

查看:140
本文介绍了如何隐藏内容页面中的Masters html按钮(没有id)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在母版页中有一个没有id&的html按钮.具有onclick功能.
我想将其隐藏在内容"页面中,我尝试了以下操作,但仍然出现错误.

Hi All,

I have a html button in Master Page without id & having a function onclick.
I want to hide it in Content page,I tried the following but I still get an error.

protected void Page_PreInit(object sender, EventArgs e)
   {
              HtmlButton btn1 = (HtmlButton)Master.FindControl("btn1");
           btn1.Visible= false;



请帮我解决这个问题.

在此先感谢.



Please help me to solve this.

Thanks in Advance.

推荐答案

嗨 首先,您需要在母版页中创建属性,例如
Hi First you need to create property in Master page like
public buttonstate 
{
  set {btn1.Visible = value;}
  get {btn1.Visible;}
}


现在您需要在内容"页面中使用,例如


Now you need to use in Content page like

Master.buttonstate = false;


注意:您可能会收到语法错误,因为我直接在这里输入..

谢谢;


Note: you may get syntax error, because i have directly type here..

Thanks;


这篇关于如何隐藏内容页面中的Masters html按钮(没有id)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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