tailieunhanh - ASP.NET 4 Unleased - p 114

Bất cứ tùy chỉnh thuộc tính mà bạn thêm vào một đồ trang web tiếp xúc của trường của lớp SiteMapNode. Ví dụ, các trang trong Ví dụ 23,15 lấy giá trị của thuộc tính metaDescription từ nút hiện tại và hiển thị các giá trị trong một tag thực tế. | 1104 CHAPTER 23 Using Site Maps siteMapNode siteMapNode siteMap Any custom attributes that you add to a Site Map are exposed by instances of the SiteMapNode class. For example the page in Listing retrieves the value of the metaDescription attribute from the current node and displays the value in an actual meta tag. LISTING Services @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD script runat server void Page_Load HtmlMeta meta new HtmlMeta Description metaDescription meta script html xmlns http 1999 xhtml head id head1 runat server title First Service title head body form id form1 runat server div h1 The First Service h1 div form body html From the Library of Wow eBook Creating Custom Site Map Providers 1105 After you open the page in Listing in a web browser you can select View Source to see the meta tag added to the source of the page see Figure . FIGURE Extending a Site Map with a meta tag. 23 It is important to emphasize that you can do anything you want with custom SiteMapNode attributes. You can represent page titles section titles product icons or anything else with a custom attribute. Creating Custom Site Map Providers Site Maps use the provider model. This means that you can easily modify or extend the way Site Maps work by creating your own Site Map provider. In this section we create two custom Site Map providers. First we create the AutoSiteMapProvider. This provider automatically builds a Site Map based on the file and folder structure of a website. Next we create a SqlSiteMapProvider. This provider enables you to store a Site Map in a Microsoft SQL Server database table instead of an XML file. From the Library of Wow eBook 1106 CHAPTER 23 Using Site Maps Creating the AutoSiteMapProvider All Site Map providers inherit from the base SiteMapProvider class. If you want to create your