📄 aspnet_masterpages.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ASP.NET 2.0 Master Pages</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>ASP.NET 2.0 - Master Pages</h1>
<a href="aspnet_newfeatures.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" /></a>
<a href="aspnet_navigation.asp"><img alt="next" border="0" src="../images/btn_next.gif" /></a>
<hr />
<p class="intro">Master pages provide templates for other pages on
your web site. </p>
<hr />
<h2>Master Pages</h2>
<p>Master pages allow you to create a consistent look and behavior for all the pages
(or group of pages) in your web application.</p>
<p>A master page provides a template for other
pages, with shared layout and functionality. The master page
defines placeholders for the content, which can be overridden by content pages.
The output result is a combination of the master page and the content page. </p>
<p>The content pages contains the content you want to display.
</p>
<p>When users request the content page,
ASP.NET merges the pages to produce output that combines the layout of the master page with the content
of the content page.
</p>
<hr />
<h2>Master Page Example:</h2>
<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td>
<pre><%@ Master %>
<html>
<body>
<h1>Standard Header For All Pages</h1>
<asp:ContentPlaceHolder id="CPH1" runat="server">
</asp:ContentPlaceHolder>
</body>
</html></pre>
</td></tr>
</table>
<p>The master page above is a normal HTML page designed as a template for
other pages.</p>
<p>The <b>@ Master</b> directive defines it as a master page.</p>
<p>The master page contains a placeholder tag <b><asp:ContentPlaceHolder></b> for
individual content.</p>
<p>The <b>id="CPH1"</b> attribute identifies the placeholder, allowing many
placeholders in the same master page.</p>
<p>This master page was saved with the name <b>"master1.master"</b></p>
<p><img border="0" src="../images/lamp.gif" width="15" height="15" alt="lamp" /> Note: The
master page can also contain code, allowing dynamic content.</p>
<hr />
<h2>Content Page Example:</h2>
<table border="1" width="100%" class="ex" cellspacing="0" id="table2">
<tr><td>
<pre><%@ Page MasterPageFile="master1.master" %>
<asp:Content
ContentPlaceHolderId="CPH1" runat="server">
<h2>Individual Content</h2>
<p>Paragrap 1</p>
<p>Paragrap 2</p>
</asp:Content></pre>
</td></tr>
</table>
<p>The content page above is one of the individual content pages of the web.</p>
<p>The <b>@ Page</b> directive defines it as a standard content page.</p>
<p>The content page contains a content tag <b><asp:Content></b> with a reference
to the master page (ContentPlaceHolderId="CPH1").</p>
<p>This content page was saved with the name <b>"mypage1.aspx"</b> </p>
<p>When the user requests this page, ASP.NET merges the content page with the
master page.</p>
<p><a target="_blank" href="mypage1.aspx">Click to display mypage1.aspx.</a></p>
<p><img border="0" src="../images/lamp.gif" width="15" height="15" alt="lamp" /> Note: The
content text must be inside the <asp:Content> tag. No content is allowed outside
the tag.</p>
<hr />
<h2>Content Page With Controls:</h2>
<table border="1" width="100%" class="ex" cellspacing="0" id="table3">
<tr><td>
<pre>
<%@ Page MasterPageFile="master1.master" %><br />
<br />&br<asp:Content<br />ContentPlaceHolderId="CPH1" runat="server"><br /><br /><h2>W3Schools</h2><br /><form runat="server"><br /><asp:TextBox id="textbox1" runat="server" /><br /><asp:Button id="button1" runat="server" text="Button" /><br /></form><br />
</asp:Content>
</pre>
</td></tr>
</table>
<p>The content page above demonstrates how .NET controls can be inserted into
the content page just like an into an ordinary page.</p>
<p><a target="_blank" href="mypage2.aspx">Click to display mypage2.aspx.</a></p>
<hr />
<a href="aspnet_newfeatures.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" /></a>
<a href="aspnet_navigation.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -