【发布时间】:2011-08-05 14:47:18
【问题描述】:
今天早上在解决一个错误时注意到了这一点。我的页面上有这样的内容:
<div id="dvDropShipMsgWrap" runat="server" visible="false" class="systemMsgCon">
<div id="dvDropShipMsg" class="systemMsg plus">
<asp:Label ID="lblAttributeDropShipMsg" runat="server" ForeColor="#333333" Visible="false"
Style="font-weight: normal;"></asp:Label>
</div>
</div>
在后面的代码中有这个:
if(myCondition)
lblAttributeDropShipMsg.Visible = p.DropShipable;
else
<snip>
dvDropShipMsgWrap.Visible = p.DropShipable;
跟踪代码,我发现 lblAttributeDropShipMsg.Visible 属性始终为 false,即使将其设置为 true。改成这样:
dvDropShipMsgWrap.Visible = p.DropShipable;
lblAttributeDropShipMsg.Visible = p.DropShipable;
解决了问题。
在设置其父级之前我无法设置嵌套控件的可见性似乎很奇怪。谁能给点启示?
【问题讨论】:
标签: c# .net-3.5 visibility