I have the following nav template:
<asp:Repeater ID="TopNavRepeat" runat="server"
DataSourceID="SiteMapDataSource1">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink ID="HyperLink1" runat="server"
Text='<%# Eval("Title") %>' NavigateUrl='<%# Eval("Url") %>'
ToolTip='<%# Eval("Description") %>' />
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
How do I render the <li> for only those sitemap nodes for which the user's role has access? (i.e. roles="Admins" in Web.sitemap)
Thanks,
Mark
-
-
mrichman wrote:How do I render the <li> for only those sitemap nodes for which the user's role has access? (i.e. roles="Admins" in Web.sitemap)
Methinks like:
<asp:Repeater ID="TopNavRepeat" runat="server"
DataSourceID="SiteMapDataSource1">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<% if(User.Identity.IsInRole( "Admins" ) { %>
<li>
<asp:HyperLink ID="HyperLink1" runat="server"
Text='<%# Eval("Title") %>' NavigateUrl='<%# Eval("Url") %>'
ToolTip='<%# Eval("Description") %>' />
</li>
<% } %>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
-
Right, but I have several roles and I want to drive it off the sitemap file like this:
<siteMapNode url="~/UserProfile.aspx" title="Profile" description="" roles="*" />
<siteMapNode url="~/Admin/Default.aspx" title="Admin" description="" roles="Admin" />
<siteMapNode url="~/Seller/Storefronts/Default.aspx" title="Storefronts" description="" roles="Seller"/>
Not sure how much conditional logic you can cram into a page without code-behind. I'm also not sure what I need to import to get "User.Identity.IsInRole" to resolve.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.