如何以编程方式更改 MasterPageFile
我有一个母版页,该母版页具有以下代码
<%@ Master Language="C#" AutoEventWireup="true" MasterPageFile="../sales/sales.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
</asp:Content>
现在这是我遇到的问题..这是站点内另一个母版页的副本,但我有多个站点将使用它,我只想为了使其对所有人通用,但我仍然想访问“..sales/sales.master”,问题是它位于每个站点文件夹内,例如,
Web/
mySite1
sales
sales.master
mySite2
sales
sales.master
但现在我需要一个主控,可以为所有人做同样的事情
Web/
All
mynewmaster.master
mySite1
sales
sales.master
mySite2
sales
sales.master
,所以在 mynewmaster.master 我想打电话MasterPageFile="../sales/sales/master" 但我不能,因为 1)它找不到它,2)它不知道该看哪一个..
sales.master 拥有我需要的所有 css。 .+其他东西我会添加..
I have a master page, and this master page has the following code
<%@ Master Language="C#" AutoEventWireup="true" MasterPageFile="../sales/sales.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
</asp:Content>
Now here is the issue i am having.. this is a copy of another master page within a site, but I have multiple sites that will be using it and I just want to make it common to all but I still want to access "..sales/sales.master" the problem is that this is within each site folder, for example
Web/
mySite1
sales
sales.master
mySite2
sales
sales.master
But now I need to have a master that will do the same for all
Web/
All
mynewmaster.master
mySite1
sales
sales.master
mySite2
sales
sales.master
so in mynewmaster.master I want to call MasterPageFile="../sales/sales/master" but I can't because 1) it would not find it and 2) it would not know which one to look at..
sales.master has all the css everything I need.. + other stuff I will add..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信你只能从
OnPreInit
更改master:I believe you can only change the master from
OnPreInit
: