• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • ASP Forum2.0學習筆記之二---了解Master Pages庫

    發表于:2007-06-30來源:作者:點擊數: 標簽:
    as .net forums界面的最關鍵的問題首先在于它使用了MetaBuilders的Master Pages 控件. 到http://www.metabuilders.com/Tools/MasterPages.aspx處下載此控件來研究一下: 一、Master Pages包括四個類: (1)Content: This control contains the content for a par
    as.net forums界面的最關鍵的問題首先在于它使用了MetaBuilders的Master Pages 控件.
    到http://www.metabuilders.com/Tools/MasterPages.aspx處下載此控件來研究一下:

    一、Master Pages包括四個類:

    (1)Content: This control contains the content for a particular region
    此類控件包含真實內容
    (2)ContentContainer: This control serves two distincts purposes: - it marks the location where the Master Page will be inserted into the Page - it contains the various Content sections that will be matched to the Master Page@#s Region controls (based on their ID@#s).
    此控件有兩個意圖:
    ·作為一個定位標志,標識Master Page將被插入到頁中;
    ·與Region Controls相匹配
    (3)NoBugForm: A server form that does not cause a problem by being inside a master page or other naming container.
    無錯form??梢苑判氖褂?
    (4)Region: The control marks a place holder for content in a master page
    占位控件

    二、我們通過分析default.aspx來看看Master Page使用方式
    (1)default.aspx的內容如下:
    <mp:ContentContainer runat="server" id="MPContainer" MasterPageFile="~/Themes/MasterPage.ascx">
    <mp:Content id="HeadTag" runat="server">
    <meta http-equiv="Refresh" content="300" />
    </mp:Content>

    <mp:Content id="MainContent" runat="server">
    <Forums:ForumGroupView runat="server" />
    </mp:Content>
    </mp:ContentContainer>
    mp:ContentContainer是一個容器,MasterPageFile="~/Themes/MasterPage.ascx是它最重要的屬性,指向了一個ascx控件頁。其實,這個ascx控件并不是一個真的ascx控件,而是一個頁面框架。它提供了default.aspx頁面的主結構,然后在其中留出了空白,讓default.aspx來填空。
    (2)再來仔細看看masterpage.ascx的內容
    <html>
    <head>
    <!--標題-->
    <Forums:PageTitle runat="server" />
    <!--風格定義-->
    <Forums:Style id="Style1" runat="server" />
    <!--頭標簽-->
    <mp:region id="HeadTag" runat="server" />
    </head>

    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

    <!-- ********* NoBugForm:START ************* //-->
    <mp:NoBugForm runat="server">

    <mp:region id="MainContent" runat="server">Default main content</mp:region>

    </mp:NoBugForm>
    <!-- ********* NoBugForm:END ************* //-->

    <!-- ********* Footer:START ************* //-->
    <Forums:Footer runat="server" /><br />
    <!-- ********* Footer:END ************* //-->
    </body>
    </html>
    首先,它有html文件的<head>,在<head>中留下了不小的地方放自定義控件,Forums:PageTitle 和Forums:Style
    然后,在Body中有一個NoBugForm,這個的作用先猜測一下,可能是指用于mp控件的form。
    最為重要的是它有一個
    <mp:region id="MainContent" runat="server">Default main content</mp:region>
    region是一個占位控件,它給誰占的位置呢?看看default.aspx就明白了:
    <mp:Content id="MainContent" runat="server">
    <Forums:ForumGroupView runat="server" />
    </mp:Content>
    看到了嗎?content中的id與region的id相匹配。結果,default.aspx將會在這兒顯示出來。
    三、優點考慮:
    現在看來master pages的結構也相對簡單。但為什么要使用這種方式而不是直接使用ascx控件呢?
    關鍵在于換膚。
    asp forums為了實現換膚的方便而使用了一個專門的ascx文件作為框架頁。而通常的ascx文件是不可能作為框架頁的,它只能是一個頁面中的一部分,我們還需要一個aspx或html文件作為框架頁。如果框架頁改變了,則所有使用此框架的頁面全部都要改過。這在dreamweaver中可以使用模板來實現,但也相當不方便。(我沒有用過模板,只知道其是自動更改使用模板的頁)但使用期master pages結構后只需要改變一個文件或幾個文件就可以實現。
    好處不少,當然缺點也不可能少。
    有什么其它不明之處,我們下回分解。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>