母版页可以多层嵌套使用
2006-08-18 08:51
393 查看
①首先是“父”母版页,与一般的母版页差不多,除了一些固定的内容,页面中间留下大片的“空白”区域:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>MasterPage可以多层嵌套使用</title>
</head>
<body>
<form id="form1" runat="server">
<table border="1" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td colspan="2" align="center" style="background-color: mediumturquoise" >MasterPage可以多层嵌套使用~~~</td>
</tr>
<tr>
<td valign="top" width="150" class="nav" style="background-color: lightcyan">
<table border="0" width="100%" cellpadding="4" cellspacing="0">
<tr>
<td><a href="#">超链接一</a></td>
</tr>
<tr>
<td><a href="#">超链接二</a></td>
</tr>
<tr>
<td><a href="#">超链接三</a></td>
</tr>
<tr>
<td><a href="#">超链接四</a></td>
</tr>
<tr>
<td><a href="#">…………</a></td>
</tr>
<tr>
<td style="font-size: x-small; color: forestgreen; ">(上面这些链接都是假的,点了也没什么效果)</td>
</tr>
</table>
</td>
<td valign="top" align="center">
<asp:contentplaceholder id="ChildMaster" runat="server" />
</td>
</tr>
<tr>
<td colspan="2" align="center" style="background-color: lightyellow" ><a href="#" onclick="window.close();">GoodBye</a></td>
</tr>
</table>
</form>
</body>
</html>
②然后是“子”母版页,它填充了上面的母板页所留下的空白,同时,再次留下3块“空白”的区域:
<asp:content id="ChildMaster" contentplaceholderid="ChildMaster" runat="Server">
<table border="1" cellpadding="10" cellspacing="0" width="100%" height="100%">
<tr>
<td align="left" colspan="2" style="font-style: italic;">“子”母版页:
</td>
</tr>
<tr>
<td align="left" colspan="2" >
<asp:contentplaceholder id="ContentTitle" runat="Server" />
</td>
</tr>
<tr>
<td align="left" valign="top" >
<asp:contentplaceholder id="ContentText" runat="Server" />
</td>
<td align="left" width="150" valign="top" >
<asp:contentplaceholder id="ContentNav" runat="Server" />
</td>
</tr>
</table>
</asp:content>
稍稍遗憾的是,上面的HTML只能手写,因为不但我们在添加一个新母版页时无法勾选“选择母版页”,并且还无法切换到设计视图:
<asp:content id="ContentTitle" contentplaceholderid="ContentTitle" runat="Server">
<h1>区域A:Content Title</h1>
</asp:content>
<asp:content id="ContentText" contentplaceholderid="ContentText" runat="Server">
<p>区域B</p>
</asp:content>
<asp:content id="ContentNav" contentplaceholderid="ContentNav" runat="Server">
<p>区域C</p>
</asp:content>
同样遗憾的是,设计上面的页面时也无法切换到设计视图。
在页面中的各个区域里设计好适当的内容后,运行起来,可以得到下面的效果:
这时候我们也许会有一个疑问:为什么要用多层嵌套的母版页?象上面的例子,一开始就在页面上
留下3块区域不是更方便吗?
大概应该这样考虑:站点可能使用一个统一的母版页所为主框架,然后在一片较大的区域中,某一些情况需要分成3块的样式,某一些则会是4块,也许还会有更复杂的要求,这时候多层嵌套就有用了。
但是问题又来了:设计起来这么不方便,该如何使用呢?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>MasterPage可以多层嵌套使用</title>
</head>
<body>
<form id="form1" runat="server">
<table border="1" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td colspan="2" align="center" style="background-color: mediumturquoise" >MasterPage可以多层嵌套使用~~~</td>
</tr>
<tr>
<td valign="top" width="150" class="nav" style="background-color: lightcyan">
<table border="0" width="100%" cellpadding="4" cellspacing="0">
<tr>
<td><a href="#">超链接一</a></td>
</tr>
<tr>
<td><a href="#">超链接二</a></td>
</tr>
<tr>
<td><a href="#">超链接三</a></td>
</tr>
<tr>
<td><a href="#">超链接四</a></td>
</tr>
<tr>
<td><a href="#">…………</a></td>
</tr>
<tr>
<td style="font-size: x-small; color: forestgreen; ">(上面这些链接都是假的,点了也没什么效果)</td>
</tr>
</table>
</td>
<td valign="top" align="center">
<asp:contentplaceholder id="ChildMaster" runat="server" />
</td>
</tr>
<tr>
<td colspan="2" align="center" style="background-color: lightyellow" ><a href="#" onclick="window.close();">GoodBye</a></td>
</tr>
</table>
</form>
</body>
</html>
②然后是“子”母版页,它填充了上面的母板页所留下的空白,同时,再次留下3块“空白”的区域:
<asp:content id="ChildMaster" contentplaceholderid="ChildMaster" runat="Server">
<table border="1" cellpadding="10" cellspacing="0" width="100%" height="100%">
<tr>
<td align="left" colspan="2" style="font-style: italic;">“子”母版页:
</td>
</tr>
<tr>
<td align="left" colspan="2" >
<asp:contentplaceholder id="ContentTitle" runat="Server" />
</td>
</tr>
<tr>
<td align="left" valign="top" >
<asp:contentplaceholder id="ContentText" runat="Server" />
</td>
<td align="left" width="150" valign="top" >
<asp:contentplaceholder id="ContentNav" runat="Server" />
</td>
</tr>
</table>
</asp:content>
稍稍遗憾的是,上面的HTML只能手写,因为不但我们在添加一个新母版页时无法勾选“选择母版页”,并且还无法切换到设计视图:
<asp:content id="ContentTitle" contentplaceholderid="ContentTitle" runat="Server">
<h1>区域A:Content Title</h1>
</asp:content>
<asp:content id="ContentText" contentplaceholderid="ContentText" runat="Server">
<p>区域B</p>
</asp:content>
<asp:content id="ContentNav" contentplaceholderid="ContentNav" runat="Server">
<p>区域C</p>
</asp:content>
同样遗憾的是,设计上面的页面时也无法切换到设计视图。
在页面中的各个区域里设计好适当的内容后,运行起来,可以得到下面的效果:
这时候我们也许会有一个疑问:为什么要用多层嵌套的母版页?象上面的例子,一开始就在页面上
留下3块区域不是更方便吗?
大概应该这样考虑:站点可能使用一个统一的母版页所为主框架,然后在一片较大的区域中,某一些情况需要分成3块的样式,某一些则会是4块,也许还会有更复杂的要求,这时候多层嵌套就有用了。
但是问题又来了:设计起来这么不方便,该如何使用呢?
相关文章推荐
- 母版页可以多层嵌套使用~
- GridView多层嵌套和折叠与展开(修改适合自己使用)
- 实战c++中的智能指针unique_ptr系列-- 使用unique_ptr来避免if多层嵌套
- ThinkPHP5 资源嵌套路由配置方法(可以根据需要实现多层嵌套) - 05
- 多层嵌套对象无法使用gson反序列化的问题The JsonDeserializer com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@3bf13cde failed to de
- AngularJS使用ui-route实现多层嵌套路由的示例
- block多层嵌套使用时,造成控制器对象不能释放
- 使用CMD模式批量删除指定目录(支持目录中多层文件夹嵌套)下指定格式文件
- [EventProxy(一)]NodeJs之使用EventProxy解决多层异步调用的嵌套
- 改进strtok是不可以嵌套使用的问题
- 实战c++中的智能指针unique_ptr系列-- 使用unique_ptr来避免if多层嵌套
- ASP.NET中Form表单不可以嵌套使用
- 使用了母版页面中FindControl(包含多层嵌套母版时)
- golang map多层嵌套使用及遍历方法汇总
- 【C语言】注释不可以嵌套使用的举例
- vector map 多层嵌套使用
- 使用UUID的优缺点和一个页面能否使用多个表单和表单之间是否可以嵌套
- GridView多层嵌套和折叠与展开(修改适合自己使用)
- JSON的简单使用之提取多层嵌套的JSON(C#)
- 自定义viewpager,他可以嵌套到大viewPage中使用