如何使表控件在内容页面中不可见 [英] How to make a table control not visible in content page

查看:97
本文介绍了如何使表控件在内容页面中不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在母版页中,我有一个表格'tgg'可见。在其中一个内容页面中,我希望这个表idtgg变得不可见。我在内容页面中使用以下代码抛出错误

like:无法将类型为'System.Web.UI.HtmlControls.HtmlTable'的对象强制转换为

' System.Web.UI.WebControls.Table'。





In master page I have a table id 'tgg' visible. In one of the content pages I want this table id 'tgg' to make invisible. I used the following code in content page which throws an error
like:Unable to cast object of type 'System.Web.UI.HtmlControls.HtmlTable' to type
'System.Web.UI.WebControls.Table'.


protected override void OnPreRender(EventArgs e)
    {
        ((Table)Master.FindControl("tgg")).Visible = false; //error on this line thrown
        base.OnPreRender(e);
    }

推荐答案

只需试试这个:

Simply Try this:
HtmlTable dt = Master.FindControl("tgg");
dt.Visible = false;



还要在表标记中添加runat =Server,以便切换其可见性/更改其css。 br />
如果你想更多地了解母版页。这里 [ ^ ]是基础教程


这篇关于如何使表控件在内容页面中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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