cnd
cnd

Reputation: 33744

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" 
              StaticSubMenuIndent="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

Upvotes: 1

Views: 590

Answers (4)

uvita
uvita

Reputation: 4124

How about using security trimming?

Upvotes: 2

Saar
Saar

Reputation: 8474

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

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

Upvotes: 0

SLaks
SLaks

Reputation: 887375

You can write Menu1.Visible = false;.

Upvotes: 0

Naeem Sarfraz
Naeem Sarfraz

Reputation: 7430

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>

Upvotes: 2

Related Questions