Attention: Another post(Set Visible property with server tag <%= %> in Framework 3.5) provides a more verbose answer to this question too.
I'm curious why the inline code does not behave as the code-behind in this case.
I have a class that contains settings as follows:
// Collection of Settings
public static class FeatureControl
{
public static bool SettingName = true;
}
Code Behind executes as expected.
Label1.Visible = FeatureControl.SettingName; //true
Label2.Visible = !FeatureControl.SettingName; //false
Inline Code always shows both labels, regardless of the SettingName's value:
<asp:Label ID="Label1" Visible="<%#FeatureControl.SettingName%>" runat="server" > </asp:Label>
<asp:Label ID="Label2" Visible="<%#FeatureControl.SettingName != true %>" runat="server" ></asp:Label>