红皮书_ASP.NET2.0网站开发全程解析_第2章_母版
2010-03-18 10:49
281 查看
让我们重头嚼起
使用母版页:
子页面:
子页面后台:
this.Master.TextBoxVisible = false; //访问母版页中定义的属性值
TextBox tb = (TextBox)this.Master.FindControl("TextBox1"); //访问母版页中控件
后续补充:
可在母版页的<head></head>标签中插入内容,以便为各子页自由包含引入文件
母版:
子页:
使用母版页:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="Master_MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>母板页</title> </head> <body> <form id="form1" runat="server"> <!-- 母板页头 star --> <div id="header" style="border:2px solid blue;margin-top:10px;padding:10px" mce_style="border:2px solid blue;margin-top:10px;padding:10px"> 母板页头<br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </div> <!-- 母板页头 end --> <!-- 母板页主体内容 star --> <div> <asp:contentplaceholder id="MasterPageContent" runat="server"> </asp:contentplaceholder> </div> <!-- 母板页主体内容 end --> <!-- 母板页脚 star --> <div id="footer" style="border:2px solid blue;margin-top:10px;padding:10px" mce_style="border:2px solid blue;margin-top:10px;padding:10px"> 母板页脚 </div> <!-- 母板页脚 end --> </form> </body> </html>
子页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Master_Default" MasterPageFile="~/Master/MasterPage.master" Title="使用通用母板页的内容页面1" %> <%@ MasterType VirtualPath="~/Master/MasterPage.master" %> <%-- 使用强类型方便访问母板 --%>
子页面后台:
this.Master.TextBoxVisible = false; //访问母版页中定义的属性值
TextBox tb = (TextBox)this.Master.FindControl("TextBox1"); //访问母版页中控件
后续补充:
可在母版页的<head></head>标签中插入内容,以便为各子页自由包含引入文件
母版:
<head runat="server"> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> </head>
子页:
asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <!-- 包含当前页显示样式 star --> <link href="../../css/ChineseClub.css" mce_href="css/ChineseClub.css" rel="Stylesheet" type="text/css" /> <!-- 包含当前页显示样式 end --> </asp:Content>
相关文章推荐
- 红皮书_ASP.NET2.0网站开发全程解析_第2章_主题
- 读《ASP.NET 2.0 网站开发全程解析》第2章
- [学习笔记]Silverlight4 RIA 开发全程解析[项目全程记录]----第零章--项目简介
- [学习笔记]Silverlight4 RIA 开发全程解析[项目全程记录]----第一章FitnessTrackerPlus应用程序概述
- Helloj2ee的新译作:Silverlight 4 RIA开发全程解析(英文名为Silverlight4 Problem Desing Solution)
- 苹果开发 笔记(74)GDataXML 解析 xml
- 【Android 多媒体开发】 MediaPlayer 状态机 接口 方法 解析
- MediaPlayer开发全解析
- Android开发之媒体扫描详细解析(上)
- [置顶] Android开发——View绘制过程源码解析(二)
- 推荐我的新书《深入理解Nginx:模块开发与架构解析》
- iOS开发教程:Storyboard全解析-第二部分
- 微信答题红包小程序开发玩法解析
- 微信公众平台java开发详解(工程代码+解析)
- 微信支付开发关键点技术解析
- 滴滴出行高效开发保障源动力解析
- Android中微信抢红包插件原理解析和开发实现
- PHP多人模块开发原理解析
- BS和CS开发架构的详细解析
- Android开发之XML文件的解析的三种方法