(1)在内容页的Page_LoadComplete事件中,通过Master.FindControl方法获取母板页控件的属性:
代码:
protected void Page_LoadComplete(object sender, EventArgs e)
{
Label2.Text = (Master.FindControl("label1") as Label).Text;
}
label1为母板页的控件ID
(2)使用MasterType指令获取母板页中控件的引用代码:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPage....
VirtualPath属性用于设定被强类型化的母板页的URL地址
转载:从内容页访问母板页