开发者

temporary Hide or Disable Master Navigate menu

on master file got ...

<div id="nav-main">
    <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" Orientation="Horizontal"
              Width="573px" CssClass="menu-main" MaximumDynamicDisplayLevels="0" 
              StaticSelectedStyle-CssClass="StaticSelectedStyle" Height="32px" 
              Sta开发者_Python百科ticSubMenuIndent="18px" >
        <StaticSelectedStyle CssClass="StaticSelectedStyle"></StaticSelectedStyle>
    </asp:Menu>

also got ...

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />

and sitemap...

got code ...

protected void Page_Load()
{
    if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
    {
    }
    else
    {
    } // sorry for formating XD

and ... I need to hide or disable then enable or show site menu (I mean visible content)

On my pages I'm making

protected void Page_Load(object sender, EventArgs e)
{
    if (!HttpContext.Current.User.Identity.IsAuthenticated)
        Response.Redirect("Default.aspx");
}

also I'm not sure if that's a good way


How about using security trimming?


Wrap it up with a LoginView control?

<asp:LoginView id="LoginView1" runat="server">
    <AnonymousTemplate>
       Please log in for personalized information.
    </AnonymousTemplate>
    <LoggedInTemplate>
       <div id="nav-main">...</div>
    </LoggedInTemplate>
<asp:LoginView>


You can write Menu1.Visible = false;.


If I understood correctly, you want to hide/show menu base on user authenticated or not.

Menu1.Visible = HttpContext.Current.User.Identity.IsAuthenticated;

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜