1

我尝试为列表模板实现自定义视图工具栏。我在 /TEMPLATES/CONTROLTEMPLATES 下创建 customdefaulttemplate.ascx 文件。customdefaulttemplate.ascx 中的代码:

<....>
<%@ Register TagPrefix="CustomSurvey" Assembly="HideRespondToSurvey, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d6553d11ff33f7e" Namespace="HideRespondToSurvey.code"%>
<SharePoint:RenderingTemplate ID="CustomViewToolBar" runat="server">
    <Template>
        <wssuc:ToolBar CssClass="ms-menutoolbar" EnableViewState="false" id="toolBarTbl" ButtonSeparator="<img src='/_layouts/images/blank.gif' alt='' />" RightButtonSeparator="&#160;&#160;&#160;" runat="server">
            <Template_Buttons>
                <CustomSurvey:SurveyMenu runat="server"></CustomSurvey:SurveyMenu>
            </Template_Buttons>
            <Template_RightButtons>
                  <SharePoint:PagingButton runat="server"/>
                  <SharePoint:ListViewSelector runat="server"/>
            </Template_RightButtons>
        </wssuc:ToolBar>
    </Template>
</SharePoint:RenderingTemplate>

我创建了继承自 Microsoft.SharePoint.WebControls.NewMenu 的类 SurveyMenu,并在 CreateChildControls() 中放置了我的逻辑。在“视图”下的列表架构模板中,我设置了 ToolBarTemplate="CustomViewToolBar"。我的列表是调查列表,但它具有附加字段和事件接收器逻辑。它在 ListTemplate 定义中具有唯一的类型。我使用功能部署列表,在网站上创建列表实例,但我的工具栏没有出现。我使用此处此处描述的方法创建此工具栏,但它不起作用。

也许您可以获取一些关于这个主题的有用资源,或者假设它可能不起作用。谢谢。

4

1 回答 1

0

您是否考虑过在 UI 功能区上创建自定义操作?我已经完成了一些事情,您可以使其仅适用于所有列表,您指定的一些列表,并且您不必经历在页面上创建和放置 Web 部件的痛苦。

于 2011-02-28T20:18:18.803 回答