TEST. ASPX-=> This is the HTML code of the displayed page.
- <Asp: SiteMapPath ID = "SiteMapPath1" runat = "server">
- </Asp: SiteMapPath>
- <! -- If you want to add a style, you can handle it yourself. Here we only implement functions. -->
Web. sitemap-=> This is a website map structure. You can define a tree or rewrite the file dynamically. However, I am currently trying xml code.
- <? Xml version = "1.0" encoding = "UTF-8"?>
- <SiteMap xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
- <SiteMapNode url = "/test. aspx" title = "" "description =" ">
- <SiteMapNode title = "create user" url = "/test. aspx? Id = 1 "/>
- <SiteMapNode title = "list user" url = "/test. aspx? Id = 12 "/>
- <SiteMapNode title = "My information" url = "/test. aspx? Id = 13 "/>
- <SiteMapNode title = "my friend" url = "/test. aspx? Id = 14 ">
- <SiteMapNode title = "White List" url = "/test. aspx? Id = 15 "/>
- <SiteMapNode title = "Blacklist" url = "/test. aspx? Id = 16 "/>
- </SiteMapNode>
- </SiteMapNode>
- </SiteMap>
Web. config-=> Add the configuration tag in <system. web/>. The defaultProvider attribute is the default xml code displayed.
- <SiteMap defaultProvider = "default" enabled = "true">
- <Providers>
- <Clear/>
- <Add name = "default" type = "System. Web. XmlSiteMapProvider" siteMapFile = "Web. sitemap" securityTrimmingEnabled = "false"/>
- </Providers>
- </SiteMap>
-----------------------------------------------------
The above is the most basic use of the control, so let's take a look at how to better optimize him, in fact, a friend with a focus should find that, the control has the same template function as the DATALIST control. It can bind user data to achieve DIY. Let's take a simple example.
For example, I used the SiteMapPath control, but I don't want its connotation hyperlink. I only need plain text to display it, so you can use the <NodeTemplate/> template to implement it, the data binding format uses the displayed text as an example: <% # Eval ("title") %>
We can do the following: HTML code
- <Asp: SiteMapPath ID = "SiteMapPath1" runat = "server" ShowToolTips = "False">
- <NodeTemplate>
- <% # Eval ("title") %>
- </NodeTemplate>
- </Asp: SiteMapPath>