~masterurl/default.master 不存在
我尝试创建自定义 Web 部件页面。我尝试了以以下内容开头的书籍示例:
<%@ Page MasterPageFile="~masterurl/default.master"
Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,
Microsoft.SharePoint, [full 4-part assembly name]"
meta:progid="SharePoint.WebPartPage.Document" %>
...但没有结果... 该页面已部署到 _layouts 文件夹中,但当我尝试从浏览器访问它时,我得到:“_layouts/~masterurl/default.master 不存在”。 我做错了什么?
先感谢您 !
解决了问题:再次阅读这本书,实际上我不必将页面添加到 _layouts 文件夹中。谢谢你让我大开眼界:)。书中对所有步骤都有很好的解释,但我不够集中注意力。是的,一落千丈……
I try to create a custom webpart page. I tried a book example that start with :
<%@ Page MasterPageFile="~masterurl/default.master"
Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,
Microsoft.SharePoint, [full 4-part assembly name]"
meta:progid="SharePoint.WebPartPage.Document" %>
....but no result....
The page is deployed into _layouts folder but when I try to access it from browser I get : "_layouts/~masterurl/default.master does not exist".
What I do wrong ?
Thank you in advance !
Solved the problem : read again the book and indeed I did not have to add the page to _layouts folder. Thank you for opening my eyes :). All steps are well explain in the book but I was not concentrating enough. Yes, one down....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您首先需要决定您的页面是否将成为站点页面(意味着它位于文档库中或直接位于 Web 中),或者是否将成为应用程序页面。如果您将该页面部署到 _layouts 文件夹,您就是在告诉 SharePoint 这是一个应用程序页面。
如果您查看其他 _layouts 页面,它们的格式为
您可以将 application.master 更改为不同的文件。
这只是执行此操作的一种方法,但是我相信还有其他选项,具体取决于您希望母版页文件的动态程度。
You first need to decide weather your page is going to be a Site Page (meaning it lives in a document library or directly in the Web), or if it is going to be an Application Page. If you deploy the page to the _layouts folder you're telling SharePoint this is an Application Page.
If you look at other _layouts pages, they have the format
You could change application.master to a different file then.
This is only one way to do this, however I believe that are other options depending on how dynamic you want the master page file to be.
它只是不喜欢
~masterurl
部分。我使用了
~/_catalogs/masterpage/filename.master
并且效果很好。不是动态的,但它适合我们的环境。It just doesn't like the
~masterurl
part.I've used
~/_catalogs/masterpage/filename.master
and that works perfectly. Not dynamic, but it works fine for our environment.类背后的代码必须派生自 WebPartPage 而不是 LayoutsPageBase。
这对我有用。
The code behind class must derive from WebPartPage rather than LayoutsPageBase.
This worked for me.
您是否正在手动编写 Web 部件页面?这通常是通过在 SharePoint 网站中创建文档库然后向其中添加 Web 部件页面来自动完成的。另外我不确定 Page 指令是否有效。查找(自动生成的)Web 部件页面的源代码,我有
但是,如果您可能的话,我再次鼓励您使用自动创建的 Web 部件页面。
Are you writing a web part page by hand? That is usually done automatically by creating a document library within a SharePoint site and then adding a web part page to it. In addition I'm not sure that Page directive is valid. Looking the source for an (automatically-generated) web part page, I have
But, again, I would encourage you to use the automatic creation of web part pages if that's possible for you.
Jon 是对的,您无法在 _layouts 文件夹中创建 Web 部件页面。他们没有设置 Web 部件基础结构。您只能在那里拥有应用程序页面。
我确定您的书没有告诉您将 Web 部件页面放在 _layouts 文件夹中?
Jon is right, you can't make a web part page in the _layouts folder.. they don't have the web part infrastructure set up. You can only have application pages there.
I'm sure your book doesnt tell you to put the web part page in the _layouts folder?