Webform---母版页(Master Pages)
母版页(Master Pages)为网站内的其他页面提供模版。
Master Page 使您有能力为 web 应用程序中的所有页面(或页面组)创建一致的外观和行为。
Master Page 为其他页面提供了模版,带有共享的布局和功能。Master Page 为内容定义了可被内容页面覆盖的占位符。而输出结果就是 Master Page 和内容页面的组合。
内容页包含您希望显示的内容。
当用户请求内容页时,ASP.NET 会对页面进行合并以生成输出,输出结果对 Master Page 的布局和内容页面的内容进行了合并。
=======================================================================================================
导航和页脚母页版
MP1.master:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MP1.master.cs" Inherits="MP1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="csss/css1.css" rel="stylesheet" />
<script src="<%=abc() %>"></script>//解决JS文件路径不统一的问题
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div> <div id="header">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder> <div id="footer"></div> </div>
</form>
</body>
</html>
MP1.master.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class MP1 : System.Web.UI.MasterPage
{
public void mp1_aaa(string s)
{
TextBox1.Text = s;//接收传值
} public string abc()
{
return ResolveClientUrl("js/js1.js");
} protected void Page_Load(object sender, EventArgs e)
{ }
}
嵌入了mp1的左标签母页版
MP2.master.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class MP2 : System.Web.UI.MasterPage
{
public void aaa(string s)
{
TextBox1.Text = s; MP1 mp1 = this.Master as MP1;//传值
mp1.mp1_aaa(s); } protected void Page_Load(object sender, EventArgs e)
{ }
}
MP2.master
<%@ Master Language="C#" MasterPageFile="~/MP1.master" AutoEventWireup="true" CodeFile="MP2.master.cs" Inherits="MP2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style>
#left {
position: relative;
width: %;
height: 300px;
background-color: yellow;
float: left;
}
#right {
position: relative;
width: %;
height: 300px;
background-color: aqua;
float: left;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="left">
这里是标题1<br />
<br />
这里是标题1<br />
<br />
这里是标题1<br />
<br />
这里是标题1<br />
<br />
这里是标题1<br />
<br />
这里是标题1<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<div id="right">
<asp:ContentPlaceHolder ID="MP2_Content" runat="server"></asp:ContentPlaceHolder>
</div>
<div style="clear: both;"></div>
</asp:Content>
这里是MP1掏出来的第二个页面
<%@ Page Title="" Language="C#" MasterPageFile="~/MP1.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <h1>这里是MP1掏出来的第二个页面</h1> </asp:Content>
这里是MP2套出来的页面
<%@ Page Title="" Language="C#" MasterPageFile="~/MP2.master" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MP2_Content" Runat="Server">
<h1>这里是MP2逃出来的页面11111</h1>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Content>
mp2套出来的页面.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += Button1_Click;
} void Button1_Click(object sender, EventArgs e)
{
//1、把本页面中的文本框的值取出来
string s = TextBox1.Text; //2、把取出来的值放到母版页的文本框中去
MP2 mp2 = this.Master as MP2;
mp2.aaa(s); }
}
Webform---母版页(Master Pages)的更多相关文章
- ASP.NET MVC- VIEW Creating Page Layouts with View Master Pages Part 4
In this tutorial, you learn how to create a common page layout for multiple pages in your applicatio ...
- 【2017-05-25】WebForm母版页
母版页:可以把界面的部分代码进行重用 添加新项-母版页 在母版页中界面代码不要写在 <asp:ContentPlaceHolder ID="head" runat=" ...
- WebForm母版页
母版页:可以把界面的部分代码进行重用 添加新项-母版页 在母版页中界面代码不要写在 <asp:ContentPlaceHolder ID="head" runat=" ...
- 使用 AngularJS 开发一个大规模的单页应用(SPA)
本文的目标是基于单页面应用程序开发出拥有数百页的内容,包括认证,授权,会话状态等功能,可以支持上千个用户的企业级应用. 下载源代码 介绍 (SPA)这样一个名字里面蕴含着什么呢? 如果你是经典的S ...
- mvc 母版页、用户自定义控件
母版页(Master) 1.母版页是与Controller无关的,母版页只是一个View文件,而没有任何Controller与之相对应. 2.其实在ASP.NET MVC中View的aspx与母版页并 ...
- 使用SharePoint 2010 母版页
SharePoint 2010母版页所用的还是ASP.NET 2.0中的技术.通过该功能,实现了页面框架布局与实际内容的分离.虽然在本质上自定义母版页的过程和以前版本的SharePoint大致相同,但 ...
- 转载 SharePoint 2013配置Master Page and Page Layout
转载原地址: http://www.cnblogs.com/huangjianwu/p/4539706.html 涉及到的内容是关于SharePoint 2013如何部署自定义的母版页和布局页. 进入 ...
- MVC与WebForm的简单的比较
MVC与WebForm的简单的比较 ASP 强制程序员将业务逻辑和展示页放到一个文件中 WebForm 允许程序员将业务逻辑与页面展示分开到不同的文件中,并且提供强大的开发平台来写 业务逻辑代码 ...
- SharePoint 2013 Deploy Master Page And Page Layout
2013年9月27日的一篇随笔,其实也是自己编写的部署文档,由于客户是HK的,所以描述部分是用英文. 涉及到的内容是关于SharePoint 2013如何部署自定义的母版页和布局页. First, L ...
随机推荐
- Lua中元表的学习
--table 中我们可以访问对应的key来得到value值,但是却无法对两个 table 进行操作. --元表(Metatable),允许我们改变table的行为,可以对两个table进行操作 -- ...
- 开关灯问题 BulbSwitch
2018-06-17 11:54:51 开关电灯问题是一个比较经典的趣味数学题,本文中主要介绍其中的一些常见情况. 一.Bulb Switch 问题描述: 问题求解: 初始状态:off, off, o ...
- Java基础十一--多态
Java基础十一--多态 一.多态定义 简单说:就是一个对象对应着不同类型. 多态在代码中的体现: 父类或者接口的引用指向其子类的对象. /* 对象的多态性. class 动物 {} class 猫 ...
- C语言的的free和c++的delete的区别
首先free对应的是malloc:delete对应的是new:free用来释放malloc出来动态内存,delete用来释放new出来的动态内存空间. 应用的区别为: 1. 数组的时候int *p=( ...
- ASCII 对照表
ASCII(American Standard Code for Information Interchange,美国信息互换标准代码,ASCⅡ)是基于拉丁字母的一套电脑编码系统.它主要用于显示现代英 ...
- LeetCode--219--存在重复元素2
问题描述: 给定一个整数数组和一个整数 k,判断数组中是否存在两个不同的索引 i 和 j,使得 nums [i] = nums [j],并且 i 和 j 的差的绝对值最大为 k. 示例 1: 输入: ...
- 20161208xlVBA工作表数据导入Access
Sub InsertToDataBase() Dim DataPath As String Dim SQL As String Const DataName As String = "yun ...
- ns-3
二.NS-3C++脚本的编写如前所述,NS-3的脚本使用C++语言(也支持python),使用四种类型的网络构件(Node.NetDevice.Channel.Application).一个简单的脚本 ...
- python-day53--前端js
一.基本语法(ECMA) 单行注释 // /* 多行注释 */ 变量赋值 默认以换行符作为结束符,有分好以分号作为结束符号 JS的引入方式: 1. <script> </script ...
- MySQL查看一个表的创建文本以及删除表某列的索引
#查看vrv_paw_area创建文本,使用这句话主要是为了找到该表对应字段上的索引名称show create table vrv_paw_area; #删除vrv_paw_area表的‘name’索 ...