动态更换母版页怎么换? 一个母版 - 母版有个名字控件一个内容页A一个内容页B两个内容页都是调用母版如何实现当我打开的是内容A 则 将母版的控件A显示为 内容A 如果打开的是内容页2 则显示内容2怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 重写(override)你的页面的MasterPageFile属性,例如(仅仅是举例)public override string MasterPageFile{ get { if (base.MasterPageFile == "1234") { base.MasterPageFile = "1234"; } return base.MasterPageFile; } set { base.MasterPageFile = value; }} 噢,示例中应该把 base.MasterPageFile == "1234" 改为 base.MasterPageFile != "1234" 你只有一个母版页,就不是动态更换母版页,你只要在页面加载的时候 protected void Page_Load(object sender, EventArgs e) { ((Label)this.Master.FindControl("Label1")).Text = "A"; }A页面 给母版页Label.Text="A"B页面 给母版页Label.Text="B"就行了要更换母版页 的话就得在页面预初始化是更换代码也就是 protected override void OnPreInit(EventArgs e) { this.MasterPageFile = "~/MasterPage2.master"; base.OnPreInit(e); }不过注意一点就是 要换的母版页必需与当前母版页控件一致 请教asp.net 2.0和SQL2005发布网站到虚拟空间的问题 js计算 很奇怪的 新手 求一个SQL文 是MYSQL的数据库 望高手给于指导 马上给分 有个比较新的问题关于c#解析自定义公式的问题 File.Copy 如何使用 ASP.NET 菜单设计 一个简单的问题~~在线等待~! js的问题 RowSelectorColumn怎么才能在一个datagrid中同时放2个或者2个以上的RowSelectorColumn? asp.net web向rdlc传参数 折腾了半个月了 跪求高手解决一下 *********高分求教线程*********
{
get
{
if (base.MasterPageFile == "1234")
{
base.MasterPageFile = "1234";
}
return base.MasterPageFile;
}
set
{
base.MasterPageFile = value;
}
}
就不是动态更换母版页,你只要在页面加载的时候
protected void Page_Load(object sender, EventArgs e)
{
((Label)this.Master.FindControl("Label1")).Text = "A";
}A页面 给母版页Label.Text="A"
B页面 给母版页Label.Text="B"
就行了要更换母版页 的话就得在页面预初始化是更换代码也就是
protected override void OnPreInit(EventArgs e)
{
this.MasterPageFile = "~/MasterPage2.master";
base.OnPreInit(e);
}
不过注意一点就是 要换的母版页必需与当前母版页控件一致