How do I disable an if the user is not logged in?
<asp:MenuItem NavigateUrl="~/Customizations.aspx" Text="Customizations" Enabled="<%# Page.User.Identity.IsAuthenticated %>" />
Doesn’t work, even if I specify Page.DataBind() in the Page_Load method.
<% if (HttpContext.User.Identity.IsAuthenticated) { %>
<asp:MenuItem NavigateUrl="~/Customizations.aspx" Text="Customizations" />
<% } %>
Gives the error: Parser Error Message: Code blocks are not supported in this context.
I tried adding an ID attribute, and it gives an error saying it isn’t a supported attribute.
Any ideas?
While trying to make webforms like winforms, Microsoft came up short and hasn’t faithfully represented a lot of the properties in the winforms MenuItem object, specifically the Visible property. They’ve also sealed the class barring the ability to work around this oversight through polymorphism.
It would be brilliant to be able to do something like this:
You’re unfortunately probably going to have to resort to either building or modifying your list in the code-behind.