开发者

ASPX in-line code evaluation when parent container is not visible

given the following in-line aspx c# code, if the parent panel (pnlX) had its visibility property set to false in the page load event, would the in-line code be hit?

<asp:Panel ID="pnlX" runat="server">
    <h1>Value is: <%= objectX.prop %></h1>
</asp:Panel>

The reason i ask is that there is some conditional logic (below) where one path sets the objectX object to something. The other path d开发者_JAVA技巧oes not and at the same time sets plnX.Visibility to false. My problem is that i am still getting null reference exceptions on objectX.

objectX = null;
if (true)
{
    objectX = something..
}
else
{
    pnlX.Visible = false;
}

Ta


Have you tried declaring the Panel with Visible="false" in the .aspx file, and then, in your code, instead of setting Visible to false if you don't need the panel, set it to true if you do? I believe that will get around your problem of the null reference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜