成免费的crm,久久国产精品新农夫导航新妓网,恋夜秀场全部视频安卓手机,女校花强奷在线播放A级

ASP.NET 母版頁

asp.net web forms - 母版頁

母版頁為您的網站的其他頁面提供模版。

母版頁

母版頁允許您為您的 web 應用程序中的所有頁面(或頁面組)創建一致的外觀和行為。

母版頁為其他頁面提供模版,帶有共享的布局和功能。母版頁為內容定義了可被內容頁覆蓋的占位符。輸出結果是母版頁和內容頁的組合。

內容頁包含您想要顯示的內容。

當用戶請求內容頁時,asp.net 會對頁面進行合并以生成結合了母版頁布局和內容頁內容的輸出。

母版頁實例

<%@ master %>

<html>
<body>
<h1>standard header from masterpage</h1>
<asp:contentplaceholder id="cph1" runat="server">
</asp:contentplaceholder>
</body>
</html>

上面的母版頁是一個為其他頁面設計的普通 html 模版頁。

@ master 指令定義它為一個母版頁。

母版頁為單獨的內容包含占位標簽 <asp:contentplaceholder>

id="cph1" 屬性標識占位符,在相同母版頁中允許多個占位符。

這個母版頁被保存為 "master1.master"

lamp 注釋:母版頁也能夠包含代碼,允許動態的內容。

內容頁實例

<%@ page masterpagefile="master1.master" %>

<asp:content contentplaceholderid="cph1" runat="server">
<h2>individual content</h2>
<p>paragraph 1</p>
<p>paragraph 2</p>
</asp:content>

上面的內容頁是站點中獨立的內容頁中的一個。

@ page 指令定義它為一個標準的內容頁。

內容頁包含內容標簽 <asp:content>,該標簽引用了母版頁(contentplaceholderid="cph1")。

這個內容頁被保存為 "mypage1.aspx"

當用戶請求該頁面時,asp.net 就會將母版頁與內容頁進行合并。

點擊這里顯示 mypage1.aspx

lamp注釋:內容文本必須位于 <asp:content> 標簽內部。標簽外的內容文本是不允許的。

帶控件的內容頁

<%@ page masterpagefile="master1.master" %>

<asp:content contentplaceholderid="cph1" runat="server">
<h2>yapf</h2>
<form runat="server">
<asp:textbox id="textbox1" runat="server" />
<asp:button id="button1" runat="server" text="button" />
</form>
</asp:content>

上面的內容頁演示了如何把 .net 控件插入內容頁,就像插入一個普通的頁面中。

點擊這里顯示 mypage2.aspx


相關文章