Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 4 Unleased - p 115

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

1114 CHAPTER 23 Using Site Maps DataRow[] results = siteMapTable.Select(“ParentId=” + parentNode.Key); foreach (DataRow row in results) { SiteMapNode node = new SiteMapNode(this, row[“Id”].ToString(), row[“url”].ToString(), row[“title”].ToString(), row[“description”].ToString()); AddNode(node, parentNode); BuildSiteMapRecurse(siteMapTable, node); } } } } Like the custom Site Map provider that was created in the previous section, the SqlSiteMapProvider derives from the base StaticSiteMapProvider class. The SqlSiteMapProvider class overrides three methods of the base class: Initialize(), GetRootNodeCore(), and BuildSiteMap(). The Initialize() method retrieves a database connection string from the web configuration file. If a database connection string cannot be retrieved, the method throws a big, fat exception. Almost all the work happens in. | 1114 CHAPTER 23 Using Site Maps DataRow results siteMapTable.Select ParentId parentNode.Key foreach DataRow row in results SiteMapNode node new SiteMapNode this row Id .ToString row url .ToString row title .ToString row description .ToString AddNode node parentNode BuildSiteMapRecurse siteMapTable node Like the custom Site Map provider that was created in the previous section the SqlSiteMapProvider derives from the base StaticSiteMapProvider class. The SqlSiteMapProvider class overrides three methods of the base class Initialize GetRootNodeCore and BuildSiteMap . The Initialize method retrieves a database connection string from the web configuration file. If a database connection string cannot be retrieved the method throws a big fat exception. Almost all the work happens in the BuildSiteMap method. This method loads the contents of the SiteMap database table into an ADO.NET DataTable. Next it recursively builds the Site Map nodes from the DataTable. There is one special aspect of the code in Listing 23.18. It uses a SQL cache dependency to automatically rebuild the Site Map when the contents of the SiteMap database table are changed. To enable SQL cache dependencies for a database you must configure the database with either the enableNotifications tool or the aspnet_regsql tool. Use the enableNotifications tool when enabling SQL cache dependencies for a SQL Express database table and use the aspnet_regsql tool when enabling SQL cache dependencies for the full version of Microsoft SQL Server. NOTE To learn more about configuring SQL cache dependencies see Chapter 29 Caching Application Pages and Data. To enable SQL cache dependencies for a SQL Express database named SiteMapDB that contains a table named SiteMap browse to the folder that contains the SiteMapDB.mdf file and execute the following command from a Command Prompt enableNotifications SiteMapDB.mdf SiteMap From the Library of Wow eBook Creating Custom Site Map Providers 1115 You can configure your website .

TÀI LIỆU LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.