将菜单项绑定到站点地图
这让我抓狂。
我有一个导航菜单,我想根据用户角色(使用.net会员资格)显示一个导航菜单。经过几个小时和头痛(因为我的头撞在桌子上),我想知道是否有人可以指出我的方法错误。
页面:
<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>
站点地图:
<?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="XmlSiteMapProvider" enabled="true">
<providers>
<add name="XmlSiteMapProvider"
description="AugustSiteMap"
type="System.Web.XmlSiteMapProvider "
siteMapFile="AugustSiteMap.sitemap"
securityTrimmingEnabled="true" />
</providers>
</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="XmlSiteMapProvider" 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系 - 对于那些跟随者:这不是正确的答案。
尝试使用DataSource
属性而不是DataSourceId
。例如
Never mind - for those that follow: this is not the right answer.
Try using theDataSource
property instead ofDataSourceId
.e.g.