如何动态地设置母版页? [英] How to Set Master Page dynamically?

查看:297
本文介绍了如何动态地设置母版页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经要求我在其中要设置不同的母版页为根据用户ID同一页(即一个用户必须设置一个主网页,另一个用户必须设置另外一个主机)。可我们设置不同的母版页的任何页面动态?请帮助...

解决方案

 无效PAGE_ preINIT(对象发件人,EventArgs的)
{
    this.MasterPageFile =〜/ MyMaster.master;
}
 

说明::您可以动态地附加一个母版页到内容页面。由于母版页和内容页都在页面处理的初始化阶段合并后,母版页必须在此之前进行分配。通常情况下,您在preINIT级动态分配母版页。


I have requirement in which i want to set different Master Pages for the Same Page depending upon userid(i.e. for one user it must set one master page and for another user it must set another master ).Can we set different Master pages for any page dynamically?Please help...

解决方案

void Page_PreInit(Object sender, EventArgs e)
{
    this.MasterPageFile = "~/MyMaster.master";
}

Explanation: You can attach a master page dynamically to a content page. Because the master page and content page are merged during the initialization stage of page processing, a master page must be assigned before then. Typically, you assign a master page dynamically during the PreInit stage.

这篇关于如何动态地设置母版页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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