tailieunhanh - Professional Visual Basic 2010 and .neT 4 phần 7

Bây giờ bạn có một trang chủ, bạn có thể bắt đầu tạo ra các trang nội dung liên kết với nó. Để tạo một trang nội dung, bạn nhấn phải chuột vào các giải pháp trong Solution Explorer và chọn Add New Item. Chọn mẫu Web Form, và kiểm tra các hộp kiểm tra tổng thể Chọn trang. | Master Pages I 755 Creating the Content Page Now that you have a master page you can start creating content pages associated with it. To create a content page right-click on the solution in the Solution Explorer and select Add New Item. Select the Web Form template and check the Select master page check box. The settings used to create the content page in the sample project are shown in Figure 22-4. Clicking the Add button brings up a dialog that enables you to select a master page to associate with this new file as shown in Figure 22-5. FIGURE 22-4 FIGURE 22-5 756 I CHAPTER 22 ADVANCED FEATURES In this case you should only have a single master page available in the dialog though it is possible to have as many master pages as you wish in a single project. Select the page and click OK. The page created should have one Content control for each of the ContentPlaceHolder controls in the selected master page @ Page Title Language VB MasterPageFile script runat server script asp Content ID Content1 ContentPlaceHolderID head Runat Server asp Content asp Content ID Content2 ContentPlaceHolderID ContentPlaceHolder1 Runat Server asp Content asp Content ID Content3 ContentPlaceHolderID ContentPlaceHolder2 Runat Server asp Content This file is quite a bit different from a typical .aspx page. First there is none of the default HTML code script tags and DOCTYPE declarations. Second note the addition of the MasterPageFile attribute in the Page directive. This new attribute makes the association to the master page that will be used for this content page. In this case it is the file created earlier. There isn t much to show while in the Source view of Visual Studio when looking at a content page the real power of master pages can be seen when you work with the page in the designer by switching to the Design or Split view see Figure 22-6 . FIGURE 22-6 This view shows you the entire template and the two content areas that

TỪ KHÓA LIÊN QUAN