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...
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 want to multilanguage my sitemappath with global resource how should I do this?
I tried this but doesn't work what do I wrong
web.sitmap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode title='$Resources: Resource, Home' url="~/Home" >
<siteMapNode url="Login.aspx" title="$Resources: Resource, Login" />
but if I do this I see ("Nothing" separator "Nothing")
web.sitemap:
<siteMap enableLocalization="true"....
I am using a .net webforms Menu control generated from the following sitemap:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="NavigationWrapper" description="">
<siteMapNode url="/" title="Home" description="" />
<siteMapNode url="/search" title="Search" description="" />
<siteMapNode url="/contact" title="Contact" description="" />
</siteMapNode>
</siteMap>
When I click the home link, the SelectedItem property of the menu control is always null, but it works fine when clicking the other two links. I can't seem to work out why!
The only way I can seem to get around this is to create a www.abc.com/home link for my homepage, but I'd prefer not to do that.
Any help much appreciated!
Edit:
Route Collection is as follows:
routes.MapPageRoute("Home", "", "~/Default.aspx");
routes.MapPageRoute("Search", "search", "~/SearchByMap.aspx");
routes.MapPageRoute("contact", "contact", "~/Contact.aspx");
Try this:
<siteMapNode url="~/" title="Home" description="">
<siteMapNode url="/search" title="Search" description="" />
<siteMapNode url="/contact" title="Contact" description="" />
</siteMapNode>
Add this to your route collection:
public static void RegisterRoutes(RouteCollection routeCollection)
{
routeCollection.MapPageRoute("Home", "", "~/Default.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>
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=""/>