How to better use the SiteMapPath control to navigate the site

Source: Internet
Author: User
TEST. ASPX-=> This is the HTML code of the displayed page.
  1. <Asp: SiteMapPath ID = "SiteMapPath1" runat = "server">
  2. </Asp: SiteMapPath>
  3. <! -- 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.

  1. <? Xml version = "1.0" encoding = "UTF-8"?>
  2. <SiteMap xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
  3. <SiteMapNode url = "/test. aspx" title = "" "description =" ">
  4. <SiteMapNode title = "create user" url = "/test. aspx? Id = 1 "/>
  5. <SiteMapNode title = "list user" url = "/test. aspx? Id = 12 "/>
  6. <SiteMapNode title = "My information" url = "/test. aspx? Id = 13 "/>
  7. <SiteMapNode title = "my friend" url = "/test. aspx? Id = 14 ">
  8. <SiteMapNode title = "White List" url = "/test. aspx? Id = 15 "/>
  9. <SiteMapNode title = "Blacklist" url = "/test. aspx? Id = 16 "/>
  10. </SiteMapNode>
  11. </SiteMapNode>
  12. </SiteMap>

Web. config-=> Add the configuration tag in <system. web/>. The defaultProvider attribute is the default xml code displayed.

  1. <SiteMap defaultProvider = "default" enabled = "true">
  2. <Providers>
  3. <Clear/>
  4. <Add name = "default" type = "System. Web. XmlSiteMapProvider" siteMapFile = "Web. sitemap" securityTrimmingEnabled = "false"/>
  5. </Providers>
  6. </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

  1. <Asp: SiteMapPath ID = "SiteMapPath1" runat = "server" ShowToolTips = "False">
  2. <NodeTemplate>
  3. <% # Eval ("title") %>
  4. </NodeTemplate>
  5. </Asp: SiteMapPath>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.