|
aspnet 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>
(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>
http://www.microsoft.com/taiwan/msdn/library/2004/oct-2004/masterpages.htm
|