Simple ASP. NET site map (sitemap) Tutorial

Source: Internet
Author: User

Well, now you have the opportunity to take your own notes !. The following describes the simplest creation method.

A site map is a technology that must be used on every website. It is used to give users navigation, so as to tell users the current location. Especially for those pages with deep directories, this effect is still obvious.

For example, you can see the form of "Tianya community> Tianya Forum> Haikou.

1. Create a new site map (the same as the new aspx). The following is the xml file generated by default.
Copy codeThe Code is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<SiteMap xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<SiteMapNode url = "" title = "" description = ""> // in general, this is the first example of "Tianya community Community"
<SiteMapNode url = "" title = "" description = ""/> here is the second-level directory, for example, "Tianya Forum"
<SiteMapNode url = "" title = "" description = "/>
</SiteMap>

Now it is mainly about url writing. The url is the relative address of the current site. What should I do? For example, if you set tour. sitemap to the same layer on your homepage, then the url will be written as follows :~ /Main. aspx .. This is OK! In other words ~ /, Indicating the root directory of the application. Note that do not list the same address and related parameters (such as parameters ~ /DisplayNews/aspx? Id = 2). In this case, the request may fail. The following is my writing format:
Copy codeThe Code is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<SiteMap xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<SiteMapNode url = "~ /Main. aspx "title =" your current location: Home Page "description =" home page ">
<SiteMapNode url = "~ /Displaycancmessage. aspx "title =" View hotel information "description =" View hotel information "/>
<SiteMapNode url = "~ /DisplayNews. aspx "title =" view News "description =" view News "/>
<SiteMapNode url = "~ /DisplaySelfTour. aspx "title =" view self-help Game Information "description =" view self-help Game Information "/>
<SiteMapNode url = "~ /GoodLines. aspx "title =" "description =" "/>
<SiteMapNode url = "~ /HainanSituation. aspx "title =" Hainan overview "description =" Hainan overview "/>
<SiteMapNode url = "~ /Optional order2.aspx "title =" Hotel Reservation "description =" Hotel Reservation "/>
<SiteMapNode url = "~ /ListNews1.aspx "title =" News list "description =" News list "/>
<SiteMapNode url = "~ /Register. aspx "title =" User Registration "description =" User Registration "/>
<SiteMapNode url = "~ /ViewSpot. aspx "title =" "description =" "/>
<SiteMapNode url = "~ /DisplayArticle. aspx "title =" view article "description =" view article "/>
<SiteMapNode url = "~ /DisplayViewSpot. aspx "title =" view scenic spots "description =" view scenic spots "/>
<SiteMapNode url = "~ /Hotels. aspx "title =" hotel information "description =" hotel information "/>
</SiteMapNode>
</SiteMap>

In fact, it is basically OK here.

2. Add the site map control.

It is easy to use site maps, that is, to pull the <asp: SiteMapPath Runat = "Server" ID = "SiteMapPath1"> </SiteMapPath> Server control to the place where you need to navigate.

The above is the simplest use of site maps. Of course, there are many attributes that can be set.

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.