如何在一个内容页面上调用不同的母版页 [英] how to call defferent master page on one content page

查看:44
本文介绍了如何在一个内容页面上调用不同的母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个母版页
1. Admin.Master
2. Operator.Master
和两个内容页面
1. Default1.aspx
2. Default2.aspx
两个内容页面均继承< codeadmin.master>页面.但是当我通过操作员登录时,两个内容页面都继承了< code> Admin.Master,我希望两个页面都应该继承Operator.Master页面.

I have two master page
1.Admin.Master
2.Operator.Master
and two content page
1.Default1.aspx
2.Default2.aspx
Both content pages inherits <codeadmin.master> page.But when I login through Operator both content page inherit <code>Admin.Master ,I want both page should inherit Operator.Master page.

推荐答案

我认为您要动态更改母版页.您可以在页面中添加Pre_Init方法,并可以在该方法中更改母版页.喜欢

I think you want to change the master page dynamically. You can add a Pre_Init method in your page and in that method you can change the master page. Like

protected void Page_PreInit(object sender, EventArgs e)
{
    this.Page.MasterPageFile = "~/Operator.master";

}



如果需要,您还可以在上述方法中添加一些条件.



You also can put some condition in the above method if require.


代码项目文章将帮助 ^ ]
Codeproject article will help Interaction Between Content Page and Master Page[^]



嵌套母版页 [ ^ ]
动态更改母版页 [
Hi ,
Nested MasterPage[^]
Change Master Page Dynamically[^]


这篇关于如何在一个内容页面上调用不同的母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆