将 XsltListViewWebPart 添加到站点定义主页

发布于 2024-10-01 14:42:01 字数 229 浏览 3 评论 0原文

将 XsltListViewWebPart 添加到网站定义的 default.aspx 的最佳方法是什么?

我尝试通过从现有页面复制 XML 来以声明方式向定义的 default.aspx 添加一个,但有许多对查看和列出 guid 的引用,在配置站点之前我不会拥有这些引用。另一种方法是通过站点配置或功能激活的事件处理程序以编程方式添加到 default.aspx,但在创建站点之前无法获取对 default.aspx 的引用。

What's the best method for adding an XsltListViewWebPart to a site definition's default.aspx?

I've tried to add one to the definition's default.aspx declaratively by copying the XML from an existing page, but there are a number of references to view and list guids which I won't have until the site is provisioned. The alternative was to programmatically add to the default.aspx via a site provisioned or feature activated event handler, but it's impossible to get a reference to the default.aspx until the site has been created.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在深巷 2024-10-08 14:42:01

将如下 XML 添加到您的模块部分:

<View List="$Resources:core,lists_Folder;/MyList" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="1" />

默认情况下,SharePoint 2010 将使用 XsltListViewWebPart。您仍然可以使用旧的 ListViewWebPart 和 XML,如下所示:

<View List="$Resources:core,lists_Folder;/MyList" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="1">
    <![CDATA[
    <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
        <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
        <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
    </WebPart>
    ]]>
</View>

Add XML like this to your Module section:

<View List="$Resources:core,lists_Folder;/MyList" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="1" />

SharePoint 2010 will use the XsltListViewWebPart by default. You can still use the old ListViewWebPart with XML as follows:

<View List="$Resources:core,lists_Folder;/MyList" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="1">
    <![CDATA[
    <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
        <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
        <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
    </WebPart>
    ]]>
</View>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文