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

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Các trang trong Ví dụ 5,20 chứa hai liên kết. Cả hai liên kết bao gồm một tham số chuỗi truy vấn tổng thể được đặt tên, đại diện cho tên của một trang Master. Khi bạn nhấp vào liên kết đầu tiên, các Dynamic1.master Master Trang tải (xem hình 5.7) và khi bạn nhấp vào liên kết thứ hai | 264 CHAPTER 5 Designing Websites with Master Pages case Dynamic2 Profile.MasterPageFile Dynamic2.master break MasterPageFile Profile.MasterPageFile script asp Content ID Content1 ContentPlaceHolderID ContentPlaceHolder1 Runat Server Select a Master Page ul class selectMaster li a href DynamicContent.aspx master Dynamic1 Dynamic Master 1 a li li a href DynamicContent.aspx master Dynamic2 Dynamic Master 2 a li ul asp Content The page in Listing 5.20 contains two links. Both links include a query string parameter named master which represents the name of a Master Page. When you click the first link the Dynamicl.master Master Page loads see Figure 5.7 and when you click the second link the Dynamic2.master Master Page loads see Figure 5.8 . The page in Listing 5.20 includes a Page_PreInit event handler. This handler grabs the value of the master query string parameter and assigns the value of this parameter to a Profile property. Next the value of the Profile property is assigned to the page s MasterPageFile property. Assigning a value to the MasterPageFile property causes a Master Page to be dynamically loaded. From the Library of Wow eBook Loading Master Pages Dynamically 265 FIGURE 5.7 Displaying the Dynamic1 Master Page. 5 FIGURE 5.8 Displaying the Dynamic2 Master Page. From the Library of Wow eBook 266 CHAPTER 5 Designing Websites with Master Pages Because the name of the Master Page is assigned to a Profile property the selected Master Page loads for a user even if the user returns to the website many years in the future. The Profile object automatically persists the values of its properties for a user across multiple visits to a website. The Profile is defined in the web configuration file contained in Listing 5.21. LISTING 5.21 Web.Config xml version 1.0 configuration system.web profile properties add name MasterPageFile defaultValue Dynamic1.master properties profile system.web configuration Loading Master Pages Dynamically for Multiple Content Pages In the .

TÀI LIỆU LIÊN QUAN