久艹视频免费看,亚洲成av人综合在线观看,51久久夜色精品国产水果派解说,gogo全球大胆高清人体444

知識學(xué)堂
  • ·聯(lián)系電話:+86.023-75585550
  • ·聯(lián)系傳真:+86.023-75585550
  • ·24小時(shí)手機(jī):13896886023
  • ·QQ 咨 詢:361652718 513960520
當(dāng)前位置 > 首頁 > 知識學(xué)堂 > 網(wǎng)站建設(shè)知識
ASP.NET入門教程:ASP.NET 2.0母版頁
更新時(shí)間:2012-05-26 | 發(fā)布人:本站 | 點(diǎn)擊率:663

母版頁(Master Pages)為網(wǎng)站內(nèi)的其他頁面提供模版。

母版頁(Master Pages)

Master Page 使您有能力為 web 應(yīng)用程序中的所有頁面(或頁面組)創(chuàng)建一致的外觀和行為。

Master Page 為其他頁面提供了模版,帶有共享的布局和功能。Master Page 為內(nèi)容定義了可被內(nèi)容頁面覆蓋的占位符。而輸出結(jié)果就是 Master Page 和內(nèi)容頁面的組合。

內(nèi)容頁包含您希望顯示的內(nèi)容。本文是網(wǎng)頁教學(xué)www.webjx.com收集整理或者原創(chuàng)內(nèi)容,轉(zhuǎn)載請注明出處!

當(dāng)用戶請求內(nèi)容頁時(shí),ASP.NET 會(huì)對頁面進(jìn)行合并以生成輸出,輸出結(jié)果對 Master Page 的布局和內(nèi)容頁面的內(nèi)容進(jìn)行了合并。

Master Page 實(shí)例:

<%@ Master %>

<html>
<body>
<h1>Standard Header For All Pages</h1>

<asp:ContentPlaceHolder id="CPH1" runat="server">
</asp:ContentPlaceHolder>

</body>
</html>

Master Page 是一張為其他頁面設(shè)計(jì)的普通 HTML 模版頁。

@ Master 指令把它定義為一個(gè)張 master page。

這個(gè) master page 為單獨(dú)的內(nèi)容包含了一個(gè)占位符標(biāo)簽 <asp:ContentPlaceHolder>。

id="CPH1" 屬性標(biāo)識該占位符,在相同的 master page 中允許多個(gè)占位符。

該 master page 被保存為 "master1.master"

注釋:該 master page 也能夠包含代碼,允許動(dòng)態(tài)的內(nèi)容。

內(nèi)容頁實(shí)例:

<%@ Page MasterPageFile="master1.master" %>

<asp:Content ContentPlaceHolderId="CPH1" runat="server">

<h2>Individual Content</h2>
<p>Paragrap 1</p>
<p>Paragrap 2</p>

</asp:Content>

上面的內(nèi)容頁是獨(dú)立的內(nèi)容頁面之一。

@ Page 指令把它定義為一張標(biāo)準(zhǔn)的內(nèi)容頁面。

該內(nèi)容頁面包含了一個(gè)內(nèi)容標(biāo)簽<asp:Content>,該標(biāo)簽引用了母版頁(ContentPlaceHolderId="CPH1")。

該內(nèi)容頁被保存為 "mypage1.aspx"

當(dāng)用戶請求該頁面時(shí),ASP.NET 就會(huì)將母版頁與內(nèi)容頁進(jìn)行合并。

點(diǎn)擊這里顯示 mypage1.aspx。

注釋:內(nèi)容文本必須位于 <asp:Content> 標(biāo)簽內(nèi)。該標(biāo)簽外的文本是不被允許的。

帶有控件的內(nèi)容頁

<%@ Page MasterPageFile="master1.master" %>

<asp:Content ContentPlaceHolderId="CPH1" runat="server">

<h2>Webjx.Com</h2>
<form runat="server">
<asp:TextBox id="textbox1" runat="server" />
<asp:Button id="button1" runat="server" text="Button" />
</form>
</asp:Content>

上面的內(nèi)容頁演示了如何把 .NET 控件插入內(nèi)容頁,就像插入一個(gè)普通的頁面中。