设置后属性具有相同的值

发布于 2024-11-02 18:14:13 字数 1207 浏览 2 评论 0原文

问:

我在 .aspx 文件中有一个面板,其visibility = false,在我的代码中的某个时刻,我设置了visibility = true。但是问题是:当我跟踪代码我发现可见属性仍然等于 false ,尽管我将其设置为 true 。 我的面板名称是:pnl_DetailsGeneral

 protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (RadioButtonList1.SelectedValue == "2")
            {
                drp_Week.Enabled = false;
                gv_Details.Visible = false;
                panel_rmv.Visible = false;
                pnl_DetailsGeneral.Visible = true;//Here when i put a break point and after setting visible to true i find `pnl_DetailsGeneral.Visible = false`
                gv_DetailsGeneral.Visible = true;
                BindGridGeneral();

            }
            else if (RadioButtonList1.SelectedValue == "1")
            {
                drp_Week.Enabled = true;
                gv_Details.Visible = true;
                gv_DetailsGeneral.Visible = false;
                pnl_DetailsGeneral.Visible = false;
                if (drp_Week.SelectedValue != "-1")
                {

                    BindGrid();
                }
            }
        }

什么可能导致此问题?

Q:

I have a panel the visibility = false in the .aspx file ,at some point in my code i set the visibility = true.but the problem is: when i trace the code i find the visible property still equal false ,although i set it to true .
My panel name is :pnl_DetailsGeneral

 protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (RadioButtonList1.SelectedValue == "2")
            {
                drp_Week.Enabled = false;
                gv_Details.Visible = false;
                panel_rmv.Visible = false;
                pnl_DetailsGeneral.Visible = true;//Here when i put a break point and after setting visible to true i find `pnl_DetailsGeneral.Visible = false`
                gv_DetailsGeneral.Visible = true;
                BindGridGeneral();

            }
            else if (RadioButtonList1.SelectedValue == "1")
            {
                drp_Week.Enabled = true;
                gv_Details.Visible = true;
                gv_DetailsGeneral.Visible = false;
                pnl_DetailsGeneral.Visible = false;
                if (drp_Week.SelectedValue != "-1")
                {

                    BindGrid();
                }
            }
        }

what may cause this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

与风相奔跑 2024-11-09 18:14:13

Visible 属性有一个特殊的属性:当您读取该值时,它不仅报告控件本身,还报告其父控件。您获得的价值是“真实”的可见性。

所以显然你的控件的父控件仍然是不可见的!

当您将父级设置为可见时,您的控件也将变得可见。

The Visible property has a special property: when you read the value it not only reports on the control itself but also on it's parent. The value you get is the "real" visibility.

So apparently the parent of your control is still invisible!

When you set the parent to Visible, your control will become visible also.

So要识趣 2024-11-09 18:14:13

我相信如果任何父级具有 Visible = false,则 Control.Visible 属性将返回 false。

I believe the Control.Visible property returns false if any parent has Visible = false.

↙厌世 2024-11-09 18:14:13

一个可能的解释是通过控制层次结构的隐式可见性。

例如,如果您有一个包含其他控件的占位符,并且该占位符已将 Visible 设置为 false,则它的所有子控件也将 Visible 设置为 false,即使您自己显式设置该属性也是如此。

A possible explanation is implicit visibility through the control hierarchy.

For instance, if you have a placeholder than contains other controls, and the placeholder has visible set to false, all of it's child controls will also have Visible set the false, even if you set the property explicitly yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文