Recently, I wrote some logs in my blog, mainly because of the problems I encountered in the actual programming process. After the problem arises, you can repeat it on your own. If you are not sure about the problem, you can search for it online. Then, you can ask your classmates and colleagues to benefit a lot from the problem! Now I have posted some functional codes that I feel more useful to the Internet, and found that I did not receive comprehensive information on the Internet, and some of them could not be used at all, I posted my project code, which is absolutely practical! I hope this will help you and facilitate your use in the future! Okay, the following is the code!
First, you need to create a site map web. sitemap. It is recommended that the code in Web. sitemap in the root directory be as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Sitemap xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<Sitemapnode url = "~ /Admin. aspx "Title =" Homepage "Description =" homepage description ">
<Sitemapnode url = "~ /Admin/changepwd. aspx "Title =" Channel 1 "Description =" Channel 1 Description "/>
<Sitemapnode url = "~ /Admin/changephoto. aspx "Title =" Channel 2 "Description =" Channel 2 Description "/>
</Sitemapnode>
</Sitemap>
You can add any number of nodes to a site map. If there are many nodes, you can clarify the "parent-child relationship" of the nodes!
Then configure web. config, which is very important:
<System. Web>
<Sitemap defaultprovider = "default" enabled = "true">
<Providers>
<Add name = "default" type = "system. Web. xmlsitemapprovider" sitemapfile = "Web. sitemap" securitytrimmingenabled = "true"/>
</Providers>
</Sitemap>
</System. Web>
<! -- The name of the red part must be the same! The blue part cannot be less, or the program cannot find the map! -->
In this way, even if the configuration is complete, the following is the specific application.
My password is changed, so in ~ /Admin/changepwd. ASPX page header (usually on the top)
Insert the <asp: sitemappath> control. The code is:
<Asp: sitemappath id = "sitemappath1" runat = "server"> </ASP: sitemappath>
Now, all are OK! As for the use of the <asp: sitemapdatasource> Control to bind data on the Internet, I think it is totally unnecessary!
In fact, it is quite simple. In summary, it is to first create a site map web. sitemap and write all the nodes used in it,
Then configure web. config and write the Site Map Name!
The last step is the actual application. Add the <asp: SiteMapPath> Control to each page that may be used in the navigation!