One,Show breadcrumbs based on site map Web.sitemap (SiteMapPath control): 1. First, create a site map Web.sitemap, preferably in the root directory, if you have already created it, then add the nodes directly inside you need to add crumbs. The SiteMapPath control consists of multiple nodes, which can be grouped into the following 3 types: The root node, the parent node, the current node. Site map can be arbitrarily added, how many, but to clarify the node of the "parent-child relationship." The code in Web.sitemap is as follows:
<?xml version= "1.0" encoding= "Utf-8"?> <!--The following are breadcrumbs 1--> <sitemap xmlns= "Http://schemas.microsoft.com/A spnet/sitemap-file-1.0 "> <sitemapnode url=" ~/index.aspx "title=" Home "description=" "> <sitemapnode url=" ~/
Company.aspx "title=" Company Introduction "description=" "> <sitemapnode url=" ~/1.aspx? "title=" Company Profile "description=" "/>" <sitemapnode url= "~/2.aspx" title= "Company Target" description= "/> </siteMapNode> <sitemapnode url=" ~/new.as PX "title=" News Center "description=" "> </siteMapNode> <sitemapnode url=" ~/pruduct.aspx "title=" Product Center " Description= "" > </siteMapNode> <sitemapnode url= "~/project.aspx" title= "Project Center" description= "" > </ sitemapnode> <sitemapnode url= "~/join.aspx?" title= "Recruiting Talents" description= "" > </siteMapNode> <SITEMAPN Ode url= "~/about.aspx" title= "Contact Us" description= "" > </siteMapNode> <!--end crumbs 1--> <!-- breadcrumbs for different ASPX pages 2--> <sitemapnode url= "#" title= "* *" descrIption= "" > <sitemapnode url= "#" title= "* *" description= "> ... </siteMapNode> ... </si
Temapnode> <!--end of breadcrumbs 2--> </siteMap>
Note: A. If a URL that does not exist is listed in the URL property value, or if a duplicate URL is listed, it will cause the requesting Web application to fail. B. If you add an associated parameter (such as url= "Second.aspx?id=1″") to a URL property value, it can also cause the request Web application to fail. C. In the URL property value, you can start with a "~/" shortcut that represents the application root directory. 2. Insert Control <asp:SiteMapPath> Control, code is:
<asp:sitemappath id= "SiteMapPath1" runat= "Server" ></asp:SiteMapPath>
Just add the above code to the exact location of the ASPX file where you need to add the breadcrumbs. 3. Introduction to some of the properties of breadcrumbs (SiteMapPath controls): I can control the presentation of breadcrumbs (SiteMapPath controls) and individual links through a number of available properties. The following list provides some of these properties (see MSDN for more detail): PathSeparator: Allows you to use other characters as a link delimiter without the default greater-than sign (>). Pathdirection: Allows you to display the path from left to right, that is, from the current node, from the point to the right (roottocurrent), or the current nodes, showing the path to the root node (currenttoroot) to the right. Rendercurrentnodeaslink: Used to indicate whether the current node is displayed as a link. This is a Boolean value. Pathlevelsdisplayed: Allows you to specify the number of layers of the structure you want to display. ShowToolTips: Used to indicate whether to display ToolTip information when the mouse is moved over a link. The tooltip information is defined in the node description attribute of the site map file. Such as:
<!--style 1-->
<asp:sitemappath id= "SiteMapPath1" runat= "Server" >
<PathSeparatorTemplate>
<asp:image id= "Image1" runat= "Server"
Width= "Imageurl=" "
uploadfiles/0022.gif"/>
</PathSeparatorTemplate>
</asp: Sitemappath>
<!--style 2-->
<asp:sitemappath id= "SiteMapPath2" runat= "Server"
pathdirection= "Currenttoroot"
pathseparator= "<--" >
</asp:SiteMapPath>
<!--style 3-->
< Asp:sitemappath id= "SiteMapPath3" runat= "Server"
skiplinktext= "Skip menu"
rootnodestyle-font-names= " Verdana "
rootnodestyle-forecolor=" Orange "
rootnodestyle-borderwidth=2 >
</asp:sitemappath >
<!--style 4-->
<asp:sitemappath id= "SiteMapPath4" runat= "Server"
pathseparator= "::" >
</asp:SiteMapPath>
The following is a number of online data screening: 1. Some information on the Internet to configure Web.config:
<system.web>
<sitemap defaultprovider= "Default" enabled= "true" >
<providers>
< Add name= "Default" type= "System.Web.XmlSiteMapProvider" sitemapfile= "Web.sitemap" securitytrimmingenabled= "true"/ >
</providers>
</siteMap>
</system.web>
<!--"defaultprovider=" default and "name=" default "" must be the same!sitemapfile= "Web.sitemap" can not be less, otherwise the program could not find the map!-->
But I found that I did this project when the development environment (Visual Studio 2010) is not, do not know other development environment is not the same, also written in this for your reference. 2. There is some information on the web that uses <asp:SiteMapDataSource> controls to bind data, but crumbs (SiteMapPath control) There is a more interesting place is that It does not need to use the SiteMapDataSource control as the menu and TreeView controls do. The SiteMapPath control is bound to the site map file by default (that is, it is placed in the root of the application).
Second,Add a subweb map file to the root site map to show breadcrumbs (SiteMapPath control): <. ----> to be continued