如何从_layout SharePoint页面使用网站的母版页? [英] How to use the site's masterpage from a _layout SharePoint page?

查看:96
本文介绍了如何从_layout SharePoint页面使用网站的母版页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的SharePoint 12 hive/template/layouts/TelephoneBookList/test.aspx文件中使用一个masterpagefile(如果有意义的话,该站点是一个).但是,每当我将MasterPageFile =〜/_layouts/simple.master"或类似的内容添加到我的test.aspx页面时,我都会在日志文件中看到一个共享点错误页面和以下内容:

I want to use a masterpagefile (the site's one if this makes sense) in my SharePoint 12 hive/template/layouts/TelephoneBookList/test.aspx file. However, whenever I add MasterPageFile="~/_layouts/simple.master" or something like that to my test.aspx page, I get a sharepoint error page and the following in the log file:

2009年1月12日10:56:26.95 w3wp.exe(0x1064)0x1280 Windows SharePoint Services拓扑0严重无效的URL: http://localhost .您可能还需要更新所有引用 http://mcdevsp 的备用访问映射.有关此错误的帮助: http://go.microsoft.com/fwlink/?LinkId=114854

01/12/2009 10:56:26.95 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services Topology 0 Critical Invalid URL: http://localhost. You may also need to update any alternate access mappings referring to http://mcdevsp. Help on this error: http://go.microsoft.com/fwlink/?LinkId=114854

2009年1月12日10:56:27.09 w3wp.exe(0x1064)0x1280 Windows SharePoint Services常规8dzz高异常类型:System.Web.HttpException异常消息:文件'/_layouts/TelephonebookList/〜masterurl/default.主人"不存在.

01/12/2009 10:56:27.09 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services General 8dzz High Exception Type: System.Web.HttpException Exception Message: The file '/_layouts/TelephonebookList/~masterurl/default.master' does not exist.

2009年1月12日10:56:27.23 w3wp.exe(0x1064)0x1280 Windows SharePoint Services拓扑0严重无效的URL: http://localhost .您可能还需要更新所有引用 http://mcdevsp 的备用访问映射.有关此错误的帮助: http://go.microsoft.com/fwlink/?LinkId=114854

01/12/2009 10:56:27.23 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services Topology 0 Critical Invalid URL: http://localhost. You may also need to update any alternate access mappings referring to http://mcdevsp. Help on this error: http://go.microsoft.com/fwlink/?LinkId=114854

2009年12月1日10:56:27.70 w3wp.exe(0x1064)0x1280 Windows SharePoint Services常规8dzw中spHttpHandler:GetHash已启动

01/12/2009 10:56:27.70 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services General 8dzw Medium spHttpHandler:GetHash started

2009年12月1日10:56:27.70 w3wp.exe(0x1064)0x1280 Windows SharePoint Services常规8dzx中号spHttpHandler:GetHash完成

01/12/2009 10:56:27.70 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services General 8dzx Medium spHttpHandler:GetHash finished

没有MasterPageFile属性,它可以完美运行,但是它没有全局Look&网站的感觉.

Without the MasterPageFile attributes, it works perfectly, however it does not have the global Look & Feel of the web site.

非常感谢.

推荐答案

尝试一下:

将MasterPageFile声明保留为默认设置(〜/_layouts/simple.master),并在您的自定义代码中覆盖OnPreInit.

Leave the MasterPageFile declaration at it's default (~/_layouts/simple.master) and override OnPreInit in your custom code.

protected override void OnPreInit(EventArgs e)
{
    base.OnPreInit(e);

    this.MasterPageFile = SPContext.Current.Web.MasterUrl;
}

这篇关于如何从_layout SharePoint页面使用网站的母版页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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