Using a <asp:SiteMapPath> control with the Web.sitemap file below:
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath>
<asp:Image ID="Image1" runat="server" ImageUrl="~/closed-sign.jpg" Height="300" Width="400" />
While running it's not showing me way it should show as in this example.
It's only showing the image, with no sitemap.
How can this be fixed?
<?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 Page">
<siteMapNode url="StandardToolBox.aspx" title="Standard ToolBox Control" description="Standard ToolBox Control">
<siteMapNode url="BulletedList.aspx" title="BulltedList Example" description="BulltedList Control Simple Example" />
<siteMapNode url="CheckBox.aspx" title="CheckBox Example" description="CheckBox Control Simple Example" />
<siteMapNode url="CheckBoxList.aspx" title="CheckBoxList Example" description="CheckBoxList Control Simple Example" />
<siteMapNode url="Image.aspx" title="Image Control Example" description="Image Control Simple Example"/>
</siteMapNode>
<siteMapNode url="DataToolBox.aspx" title="Data ToolBox Control" description="Data ToolBox Control">
<siteMapNode url="SqlDataSource.aspx" title="SqlDataSource Example" description="SqlDataSource Simple Example" />
<siteMapNode url="XmlDataSource.aspx" title="XmlDataSource Example" description="XmlDataSource Simple Example" />
</siteMapNode>
The code you're using works fine.
Likely the page you're looking at is NOT anywhere in the list on the site map.
Ensure you're running this sample on a page named like:
StandardToolBox.aspx
CheckBox.aspx
DataToolBox.aspx
This is a breadcrumb control. It will only show links back to its parents. It will not send links to siblings.
Related
I am new to Asp.net and I had some trouble with menu navigation.
I had the Web.sitemap
<siteMapNode url="~/" title="Home" description="Home">
<siteMapNode url="~/Default" title="Home" description="Go to the homepage" />
<siteMapNode url="~/Reviews/Default" title="Reviews" description="Reviews published on this site">
<siteMapNode url="~/Reviews/AllByGenre" title="By Genre" description="All Reviews Grouped by Genre" />
<siteMapNode url="~/Reviews/All" title="All Reviews" description="All Reviews" />
</siteMapNode>
<siteMapNode url="~/About/Default" title="About" description="About this Site">
<siteMapNode url="~/About/Contact" title="Contact Us" description="Contact Us" />
<siteMapNode url="~/About/AboutUs" title="About Us" description="About Us" />
</siteMapNode>
<siteMapNode url="~/Login" title="Login" description="Log in to this web site" />
and the start page Default.aspx gives
But it just gives HTTP Error 404.0 not found errorwhen I try to navigate. URL is http://localhost:24186/About/AboutUs
url ="~/About/Default" . Try add the .aspx like
url="~/About/Default.aspx"
I am not sure though. Cant see issue otherwise. I normally add the .aspx and i think it should be there.
I have a .sitemap file that contains all of my nodes that I want to display for my side navigation. I am having trouble displaying all of my nodes when I get to the sub level. Everything just disappears when I visit the sub-page. In otherwords, when I am in the homepage.aspx page, all of my nodes are visible. When I enter the level1a.aspx page, all of the nodes disappear. I have no code behind. Is there a setting to display all nodes? Or would I need to write code to display them all?
Here are files:
web.config
<siteMap>
<providers>
<add name="SiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/my.sitemap" />
</providers>
</siteMap>
control.ascx
<asp:SiteMapDataSource ID="SiteMapDataSource1" SiteMapProvider="SiteMap" runat="server" />
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1"></asp:Menu>
my.sitemap
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="/HomePage.aspx" title="Home Page" description="">
<siteMapNode url="/level1.aspx" title="Level 1" description="">
<siteMapNode url="/level1a.aspx" title="Level 1 A" description="" />
<siteMapNode url="/level1b.aspx" title="Level 1 B" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>
I just made the experiment and it works fine...
Double check all your pages contain a reference to your user control
This is what I did
UC
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="MyMenuUC.ascx.cs" Inherits="WebApplication1.MyMenuUC" %>
<asp:SiteMapDataSource runat="server" ID="mySiteMapDataSource" ShowStartingNode="false" />
<asp:Menu runat="server" DataSourceID="mySiteMapDataSource"></asp:Menu>
Web.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="">
<siteMapNode url="~/MenuWithUC1.aspx" title="page 1" description="" />
<siteMapNode url="~/MenuWithUC2.aspx" title="page 2" description="" />
</siteMapNode>
</siteMap>
MenuWithUC1.aspx
<%# Register Src="~/MyMenuUC.ascx" TagName="SharedMenu" TagPrefix="menu" %>
....
<menu:SharedMenu runat="server" />
<asp:Button ID="Button1" Text="post me" runat="server" />
MenuWithUC2.aspx
<%# Register Src="~/MyMenuUC.ascx" TagName="SharedMenu" TagPrefix="menu" %>
....
<menu:SharedMenu runat="server" />
<asp:Button Text="post me" runat="server" />
The buttons on each page are just to test that the Menu control keeps its state on each post
try with EnableViewState = true
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" EnableViewState="true"></asp:Menu>
I have a XML file for sitemap, here it is:
<?xml version="1.0" encoding="utf-8"?>
<siteMap>
<siteMapNode url="/" title="Home" tcmId="tcm:142-2-4">
<siteMapNode url="/controls" title="Controls" tcmId="tcm:142-1131-4" type="structure group" />
<siteMapNode url="/css" title="CSS" tcmId="tcm:142-1134-4" type="structure group" />
<siteMapNode url="/js" title="JS" tcmId="tcm:142-1133-4" type="structure group" />
<siteMapNode url="/xslt" title="XSLT" tcmId="tcm:142-1132-4" type="structure group" />
<siteMapNode url="/mobile" title="Mobile" tcmId="tcm:142-1165-4" type="structure group" />
<siteMapNode url="/mobilebiscuitml" title="Mobile BiscuitML" tcmId="tcm:142-1180-4" type="structure group" />
<siteMapNode url="/system" title="system" tcmId="tcm:142-136-4" type="structure group">
<siteMapNode url="/system/captcha" title="Captcha" tcmId="tcm:142-260-4" type="structure group" />
<siteMapNode url="/system/communicator" title="Communicator" tcmId="tcm:142-201-4" type="structure group" />
<siteMapNode url="/system/errorpages" title="Error Pages" tcmId="tcm:142-322-4" type="structure group" />
<siteMapNode url="/system/includes" title="includes" tcmId="tcm:142-138-4" type="structure group" />
<siteMapNode url="/system/masterpages" title="Master Pages" tcmId="tcm:142-139-4" type="structure group" />
<siteMapNode url="/system/outboundemail" title="Outbound Email" tcmId="tcm:142-199-4" type="structure group" />
<siteMapNode url="/system/SiteEdit" title="SiteEdit" tcmId="tcm:142-214-4" type="structure group" />
<siteMapNode url="/system/ui_widgets" title="UI Widgets" tcmId="tcm:142-320-4" type="structure group" />
<siteMapNode url="/system/webtemplates" title="Web Templates" tcmId="tcm:142-333-4" type="structure group" />
<siteMapNode url="/system/xml" title="Xml" tcmId="tcm:142-141-4" type="structure group" />
</siteMapNode>
<siteMapNode url="/App_GlobalResources" title="Website Labels" tcmId="tcm:142-295-4" type="structure group" />
<siteMapNode url="/Bpo.aspx" title=" BPO" tcmId="tcm:142-10830-64" type="page" />
<siteMapNode url="/Careers.aspx" title=" Careers" tcmId="tcm:142-10692-64" type="page" />
<siteMapNode url="/bpoHitech.aspx" title=" Hitech" tcmId="tcm:142-10710-64" type="page" />
<siteMapNode url="/news.aspx" title=" News" tcmId="tcm:142-10868-64" type="page" />
<siteMapNode url="/ISD.html" title="ISD" tcmId="tcm:142-11027-64" type="page" />
<siteMapNode url="/Services.aspx" title="Services" tcmId="tcm:142-10681-64" type="page" />
<siteMapNode url="/Knowledge.aspx" title="Knowledge" tcmId="tcm:142-11170-64" type="page" />
</siteMapNode>
</siteMap>
What i've did till now:
create a function in script tag in PT DWT TBB. where,
pageload()
{ id="##Page.ID##" }
this TBB inherits a (.cs file) where i defined a id property in a class. create a object of this class type and access the property. used this property as XSLT argument and apply the transformation through xsl.
Any other suggestion'd be good.
Manoj, The below XSL might help.. I have not tested this, but used it in some past projects the xml structure is slightly different but the below snippet should help you on moving forward in the right direction.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="//siteMapNode[#title = '<<Controls>>']"> ---> Node title of the current page
<div id="breadcrumb">
<xsl:for-each select="ancestor::siteMapNode"> --> selects the parent and loop through..
<xsl:value-of select="#title"/> > --> breadcrumb separator ">"
</xsl:for-each>
<xsl:value-of select="#title"/>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Have you considered this?: http://msdn.microsoft.com/en-us/library/x20z8c51.aspx
I'm using C# ASP.NET 4 VS2010.
I'm using membership with roles, which are already defined as usual.
I have a ~/web.sitemap file that includes this:
(The ~/ security is Allow to all.)
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="" description="">
<siteMapNode url="" title="A menu for the Administrator" description="">
<siteMapNode url="~/Admin/ResetPassword.aspx" title="Reset password for a user" description="" />
<siteMapNode url="~/Admin/SendEmailToUser.aspx" title="Send e-mail to a user" description="" />
</siteMapNode>
<siteMapNode url="" title="A menu for the SIC (second in command) person" description="">
<siteMapNode url="~/SIC/UnlockUser.aspx" title="Unlock a user" description="" />
<siteMapNode url="~/SIC/ApproveUser.aspx" title="Approve a user" description="" />
</siteMapNode>
<siteMapNode url="" title="A menu for users" description="">
<siteMapNode url="~/Users/MakeYourContribute.aspx" title="Make your contribution" description="" />
<siteMapNode url="~/Users/CheckOnYourBalance.aspx" title="Check on your balance" description="" />
</siteMapNode>
<siteMapNode url="" title="A menu for anonymous visitors" description="">
<siteMapNode url="~/AboutUs.aspx" title="About us" description="" />
<siteMapNode url="~/Application.aspx" title="Send an application to join us" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>
and a web.config file that ends like this:
<siteMap defaultProvider="XmlSiteMapProvider" enabled ="true">
<providers>
<add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="~/web.sitemap" securityTrimmingEnabled="true" />
</providers>
</siteMap>
</system.web>
</configuration>
My menu is based on the asp:Repeater control and looks like this:
<div>
<ul>
<li>
<asp:hyperlink runat="server" id="lnkHome" navigateurl="~/Default.aspx">Home</asp:hyperlink>
</li>
<asp:repeater runat="server" id="menu" datasourceid="SiteMapDataSource1">
<ItemTemplate>
<li>
<asp:HyperLink ID="lnkMenuItem" runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>
<asp:Repeater ID="submenu" runat="server" DataSource="<%# ((SiteMapNode) Container.DataItem).ChildNodes %>">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink ID="lnkMenuItem" runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate> </asp:Repeater> </li> </ItemTemplate> </asp:Repeater> </ul>
<asp:sitemapdatasource id="SiteMapDataSource1" runat="server" showstartingnode="true" />
</div>
The security of allow/deny to folders is defined for the respective folders.
There are 4 levels of security: 1) Administrators. 2)Second In Command (SIC). 3) Users (all registered users). 4) Anonymous users.
For example, both the members of the Administrators role and the SIC role are allowed on the operate in the folder ~/SIC , but the rest of the users are restricted from it.
Now, as soon as I added the securityTrimmingEnabled="true" to the web.config, the only row I see on the menu is Home.
Have I configured anything wrong?
Are there any more configuration I need to make in order to have this security dependent menu work?
The problem is the empty URL in the menu headers.
<siteMapNode url="" title="A menu for the Administrator" description="">
It appears that the sitemap functionality is trying to determine the permissions for the empty url "", and failing.
A workaround is to modify the .sitemap file to explicitly state the roles that can access the parent nodes.
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="" description="" roles="*">
<siteMapNode url="" title="A menu for the Administrator" description="" roles="Administrators">
<siteMapNode url="~/Admin/ResetPassword.aspx" title="Reset password for a user" description="" />
<siteMapNode url="~/Admin/SendEmailToUser.aspx" title="Send e-mail to a user" description="" />
</siteMapNode>
<siteMapNode url="" title="A menu for the SIC (second in command) person" description="" roles="administrators,second in command">
<siteMapNode url="~/SIC/UnlockUser.aspx" title="Unlock a user" description="" />
<siteMapNode url="~/SIC/ApproveUser.aspx" title="Approve a user" description="" />
</siteMapNode>
<siteMapNode url="" title="A menu for users" description="" roles="administrators,secondincommand,users">
<siteMapNode url="~/Users/MakeYourContribute.aspx" title="Make your contribution" description="" />
<siteMapNode url="~/Users/CheckOnYourBalance.aspx" title="Check on your balance" description="" />
</siteMapNode>
<siteMapNode url="" title="A menu for anonymous visitors" description="" roles="*">
<siteMapNode url="~/AboutUs.aspx" title="About us" description="" />
<siteMapNode url="~/Application.aspx" title="Send an application to join us" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>
Admittedly, this isn't ideal, because now you are partially configuring security in two places.
Another option is to just put roles="*" on every menu header. It will still apply the permissions check on every leaf node and hide them if necessary. The downside to this is that it can then display empty menu headers.
Here is the resource which pointed me to this solution: https://web.archive.org/web/20210417091658/http://www.4guysfromrolla.com/articles/122805-1.aspx
I'm trying to make a menu based off of an asp.net sitemap. How do you nest the sitemap nodes so that they all appear on the same level. Here is what I have:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode url="~/Default.aspx" title="Home" description="link to Home" />
<siteMapNode url="~/about.aspx" title="About" description="abot" />
</siteMapNode>
</siteMap>
Here is what the code for the Menu control looks like:
<asp:Menu ID="Menu1" runat="server" BackColor="#E3EAEB"
DataSourceID="SiteMapDataSource1"
</asp:Menu>
They both appear as 2nd tier elements underneath an arrow. Sorry for the beginner question but I've never used the menu control before.
You just need to set the StaticDisplayLevels and only have one level in the sitemap file.
<asp:Menu runat="server" DataSourceID="SiteMapDataSource" StaticDisplayLevels="2" >
</asp:Menu>
An example of the web.sitemap:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode url="Default.aspx" title="Home" description="" />
<siteMapNode url="Page2.aspx" title="Page2" description="" />
</siteMapNode>
</siteMap>