【发布时间】:2010-06-16 06:51:00
【问题描述】:
当使用网络表单时,将母版页动态分配给页面的适当位置似乎是页面 PreInit 事件:
this.Master.MasterPageFile = "~/leaf.Master"
如果需要,嵌套母版页层次结构中的母版页也可以在这里设置:
this.Master.MasterPageFile = "~/leaf.Master"
this.Master.Master.MasterPageFile = "~/root.Master"
使用 MVC 框架,您可以使用控制器 View 方法通过传递 masterName 动态设置单个母版页名称,但是如何设置层次结构中更高的其他母版页?
更新
对不起,我不清楚。
我所说的层次结构是指嵌套母版页链,那么如何在嵌套母版页链中设置最顶层的母版页?
例如,我们有一个设置,不同的客户类型有不同的母版页,并且嵌套在该母版页中的是特定用户角色的附加母版页。我们需要动态设置 root 客户 master 以及角色 master。
【问题讨论】:
标签: asp.net-mvc