<?xml version="1.0" encoding="utf-8" ?>
<Home>
<Menu text="Books" url="MenuFromXml.aspx">
<SubMenu text="Asp.Net" url="MenuFromXml.aspx" id="Asp" ></SubMenu>
<SubMenu text="Ajax" url="MenuFromXml.aspx" id="AJax"></SubMenu>
<SubMenu text="MS SQL Server 2005" url="MenuFromXml.aspx" id="SQL"></SubMenu>
<SubMenu text="JavaScript" url="MenuFromXml.aspx" id="Javascript"></SubMenu>
</Menu>
The above xml file is the datasource for my menu. I want to return a url like http://www.xyzsite/MenuFromXml.aspx?Id=sql so that I can further use the query string to select required resource for each request. I need you help to solve this problem, Thank you
You can use SiteMap, the SiteMap works like XML.
In SiteMap:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="MenuFromXml.aspx" title="Book" description="">
<siteMapNode url="MenuFromXml.aspx?id=Asp.Net" title="Asp.Net" description="" />
<siteMapNode url="MenuFromXml.aspx?id=AJax" title="Ajax" description="" />
<siteMapNode url="MenuFromXml.aspx?id=SQL" title="MS SQL Server 2005" description="" />
<siteMapNode url="MenuFromXml.aspx?id=Javascript" title="JavaScript" description="" />
</siteMapNode>
</siteMap>
Related
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
So, here's what I'm working on. I have an ASP.NET web app, in which the sitemap is displayed on the site.master file through the web.sitemap.
Here's the site.master:
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<asp:TreeView
ID="TreeView1"
runat="server"
ataSourceID="SiteMapDataSource1"
ExpandDepth="1">
</asp:TreeView>
And here's the web.sitemap:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Default.aspx" title="Home" description="Home">
<siteMapNode url="" title="Projects" description="">
</siteMapNode>
<siteMapNode url="" title="Configurations" description="Configurations">
<siteMapNode url="" title="Experiments" description="Experiments">
</siteMapNode>
<siteMapNode url="" title="Cell Line" description =""></siteMapNode>
<siteMapNode url ="" title ="Drugs">
</siteMapNode>
<siteMapNode url ="" title="Manage Configurations" />
<siteMapNode url="~/ExperimentConfigurationView.aspx" title ="Configure Experiements"/>
<siteMapNode url="~/DrugConfigurationView.aspx" title="Configure Drugs"/>
</siteMapNode>
</siteMapNode>
<siteMapNode url="" title="Drug Recipes" description="">
</siteMapNode>
</siteMapNode>
</siteMap>
Now, here's where I'm running into a problem. What I'd like to do is combine this site map with a dynamically created SiteMapProvider, and populate the sub-trees of this map. For example, the Projects, Experiments, Cell Line and Drug Recipe nodes would each have a sub-tree, populated from a datebase. Anyone have input, or a suggestion as to where to start looking?
In summary - I'd like to point the leaf siteMapNodes to a SiteMapProvider.
Solution:
I added a file DrugListProvider.cs in the root directory. That holds the code for dynamically generating the sub-tree.
I placed the following node in the Web.sitemap, where I wanted the sub-tree to appear:
<siteMapNode provider="DrugListProvider"/>
Finally, I include this in the web.config file:
<siteMap>
<providers>
<add name="DrugListProvider" type="PrivoWeb.DrugListProvider"/>
</providers>
</siteMap>
I am having a problem with security trimming of menu links provided by the sitemap. If I set securityTrimmingEnabled="false", my menu works but there's no security trimming. If I set securityTrimmingEnabled="true", my menu just disappears. How can I fix this?
In web.config, I have:
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true" >
<providers>
<clear />
<add name="XmlSiteMapProvider"
description="Default SiteMap provider."
type="System.Web.XmlSiteMapProvider"
siteMapFile="Web.sitemap"
securityTrimmingEnabled="true" />
</providers>
</siteMap>
In Site.master, I have:
<div class="clear hideSkiplink">
<asp:Menu ID="Menu1" runat="server" CssClass="menu" DataSourceID="SiteMapDataSource1">
</asp:Menu>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</div>
In Web.sitemap, I have:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="***">
<siteMapNode url="" title="***">
<siteMapNode url="~/***.aspx" title="***" />
<siteMapNode url="~/***.aspx" title="***" />
<siteMapNode url="~/***.aspx" title="***" />
<siteMapNode url="~/***.aspx" title="***" />
</siteMapNode>
<siteMapNode url="" title="***">
<siteMapNode url="~/Account/***.aspx" title="***" />
<siteMapNode url="~/Account/***.aspx" title="***" />
<siteMapNode url="~/Account/***.aspx" title="***" />
<siteMapNode url="~/Account/***.aspx" title="***" />
</siteMapNode>
</siteMapNode>
</siteMap>
You need to specify roles on your nodes like this (as per this article http://msdn.microsoft.com/en-us/library/ms178428.aspx)
<siteMapNode title="Support" description="Support" url="~/Customers/Support.aspx" roles="Customers" />
All nodes are by default not displayed when securityTrimmingEnabled is enabled unless you are in one of the allowed roles. To allow all roles you can do this roles="*" (as described here http://blogs.msdn.com/b/dannychen/archive/2006/03/16/553005.aspx)
my sitemap is like:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Admin/Default.aspx" title="Administration" description="">
<siteMapNode url="~/Admin/Overview.aspx" title="Übersicht" description="">
<siteMapNode url="~/Admin/UserOverview.aspx" title="Benutzer" description="">
</siteMapNode>
<siteMapNode url="~/Admin/CompanyOverview.aspx" title="Firmen" description="">
</siteMapNode>
<siteMapNode url="~/Admin/OrganisationOverview.aspx" title="Organisationen" description="">
</siteMapNode>
</siteMapNode>
<!-- LINE BREAK SHOULD BE HERE -->
<siteMapNode url="~/Admin/Settings.aspx" title="Einstellungen" description="">
</siteMapNode>
</siteMapNode>
</siteMap>
I have a TreeView binded on it with a SiteMapDataSource.
Here is it how it looks like: http://www.imgimg.de/bild_18a9b0128PNG.png.html
How I get a Linebreak in it?
Taken from this post, you can include the following to get a <hr /> tag but you'll have to disable postback for this item.
<siteMapNode title="<hr />" description="separator" url=""/>
I have routing set up as follows:
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("", "Home", "~/Default.aspx");
......
}
I'm implementing breadcrumbs using a SiteMapPath control:
<asp:SiteMapPath ID="SiteMapPath1" CssClass="breadCrumbs" runat="server">
</asp:SiteMapPath>
Web.sitemap is set up as follows:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Home" title="Home" description="Home">
<siteMapNode url="~/About" title="About" description="About">
<siteMapNode url="~/History" title="History"
description="History" />
</siteMapNode>
</siteMapNode>
</siteMap>
My problem is that when I navigate to mysite.com instead of mysite.com/default.aspx, the Home breadcrumb node does not appear. What am I missing?
UPDATE
I managed to get the "Home" node to display by updating Web.sitemap as follows:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Home" title="Home" description="Home">
<siteMapNode url="~/Default.aspx" title="" description="" />
<siteMapNode url="~/About" title="About" description="About">
<siteMapNode url="~/History" title="History"
description="History" />
</siteMapNode>
</siteMapNode>
</siteMap>
The only remaining problem is that the path separator is still displaying on home page for mysite.com
Is there a way to programatically render the separator invisible for the home page? The SiteMapPath control itself is in a master page.
Maybe you should change your sitemap file as follows :
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/" title="Global Site Name or Welcome Message" description="Home">
<siteMapNode url="~/Home" title="Home" description="" />
<siteMapNode url="~/About" title="About" description="About">
<siteMapNode url="~/History" title="History"
description="History" />
</siteMapNode>
</siteMapNode>
</siteMap>
and from the sitemapdatasource you should set ShowStartingNode="false" and I think that this solves both of your problems at once...
NOTE: of course this will require that you made this change in the global.asax file (VB):
RouteTable.Routes.MapPageRoute("Home0", "", "~/Default.aspx", True)
RouteTable.Routes.MapPageRoute("Home1", "Home", "~/Default.aspx", True)
hope this helps...