今天上午在处理错误时注意到了这一点。我有我的网页上是这样的:嵌套控制可见性问题
<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属性将永远是假的,即使设置为true也是如此。将其更改为:
dvDropShipMsgWrap.Visible = p.DropShipable;
lblAttributeDropShipMsg.Visible = p.DropShipable;
修复了这个问题。
看起来很奇怪,我无法在设置其父项之前设置嵌套控件的可见性。任何人都可以提供一些启发吗?
非常好的解释。谢谢。 – 2011-04-15 11:27:00