开发者

Binding menu items to a sitemap

this is driving me nuts.

I have a navigation menu I would like to display based upon user roles (using.net membership) After several hours and headaches (from banging my head against the desk) I was wondering if someone can point me in the error of my ways.

Page:

<body>
    <form runat="server">
    <div class="page">
        <div class="header">
            <div class="loginDisplay">
                <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
                    <AnonymousTemplate>
                        <a href="~/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> 
                    </AnonymousTemplate>
                    <LoggedInTemplate>
                        Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                        [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/Open/Close.aspx"/> ]
                    </LoggedInTemplate>
                </asp:LoginView>
            </div>
            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" 
                    IncludeStyleBlock="False" Orientation="Horizontal"
                DataSourceID="AugustSiteMap" />
                <asp:SiteMapDataSource ID="AugustSiteMap" runat="server" ShowStartingNode="false"/>
            </div>
        </div>

SiteMap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="~/Default.aspx" title="Home"  description="Home">

    <siteMapNode title="Open Pages" description="Open Pages">
      <siteMapNode url="~/Open/Login.aspx" title="Login Page" description="Login Page" roles="*"/>
      <siteMapNode url="~/Open/Close.aspx" title="" description="" roles="*"/>

    </siteMapNode>

    <siteMapNode title="Logged In Open Pages" description="Logged In Open Pages">
      <siteMapNode url="~/Landing.aspx" title="Landing Page" description="Landing Page" roles="*"/>
      <siteMapNode url="~/ContactUs.aspx" title="Contact Us" description="Contact Us" roles="*"/>

    </siteMapNode>


    <siteMapNode title="Restricted Pages" description="Resticted Pages">
      <siteMapNode url="~/Restricted/ProductSearch.aspx" title=" Product Search" description=" Product Search" roles="*"/>
      <siteMapNode url="~/Restricted/ReportOutput.aspx" title="Report Output" description="Report Output" roles="Admin"/>
    </siteMapNode>



  </siteMapNode>

</siteMap>

Webconfig:

<roleManager enabled="true" />
      <siteMap defaultProvider="XmlSiteMapProvid开发者_运维百科er" enabled="true">
        <providers>

         <add name="XmlSiteMapProvider"
            description="AugustSiteMap"
            type="System.Web.XmlSiteMapProvider "
            siteMapFile="AugustSiteMap.sitemap"
            securityTrimmingEnabled="true" />
        </providers>
      </siteMap>

How can I ensure that when the user is logged in, the appropriate menu items are displayed on the Landing page?

The problem being that, currently, a navigation menu is not created in any way, shape or form.

Please excuse my ignorance. Still new to all of this and my current method of 'trial and error' has seen me reach suicide levels this morning!


Never mind - for those that follow: this is not the right answer.

Try using the DataSource property instead of DataSourceId.

e.g.

DataSource="AugustSiteMap"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜