Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
General Reference
List Forms
 How to: Override a Default Control ...
Community Content
In this section
Statistics Annotations (1)
This page is specific to
The 2007 product release

Other versions are also available for the following:
How to: Override a Default Control Template

You can override an existing default form template installed with Windows SharePoint Services by adding an .ascx file that contains a custom template definition to Local_Drive:\\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES. The custom control template must have the same ID as the default template.

Example

The following control template example overrides the default control template whose ID equals DocumentLibraryForm. The template adds a message to the bottom of the form with a link to another page.

<SharePoint:RenderingTemplate ID="DocumentLibraryForm" runat="server">
  <Template>
    <SharePoint:InformationBar runat="server"/>
    <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&nbsp;" runat="server">
      <Template_RightButtons>
        <SharePoint:SaveButton TabIndex=1 runat="server"/>
        <SharePoint:GoBackButton runat="server"/>
      </Template_RightButtons>
    </wssuc:ToolBar>
    <SharePoint:FormToolBar runat="server"/>
    <SharePoint:FormComponent TemplateName="DocumentLibraryFormCore" runat="server"/>
    <div style="padding-top: 40px; font: 8pt Tahoma;">
      <span style="color: red; font-weight: bold">Warning:</span>   This site contains customer data and information. <a href="_layouts/moreinfo.aspx">More information on customer data protection.</a>
    </div>
  </Template>
</SharePoint:RenderingTemplate>

To create a custom control template file for document libraries

  1. In a text editor, create an .ascx file in \12\TEMPLATE\CONTROLTEMPLATES that contains the necessary directives.

    The previous example requires the following directives:

    <%@ Control Language="C#"   %>
    <%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>
    <%@ Register TagPrefix="wssuc" TagName="ToolBar" src="/_controltemplates/ToolBar.ascx" %>
    <%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="/_controltemplates/ToolBarButton.ascx" %>
  2. Add a template definition to the .ascx file that overrides a specific default control template, such as the previous example.

  3. Reset Internet Information Services (IIS) for changes to take effect.

  4. Navigate to a form for an item in a document library to see the changes.

Community Content   What is Community Content?
Add new content RSS  Annotations
Issue with this approach      RaphaelL   |   Edit   |   Show History
I have found out that if I have two custom products trying to override the same Rendering Template (that's the case with the RadEditor and the BlueBridge Wiki Extensions for SharePoint which both override the RichTextField rendering template), SharePoint only really cares about the last loaded template (since they seem to be loaded alphabetically, RadEditorList.ascx takes precedence over bbWikiEditorV2.ascx).

Is there a way multiple rendering templates can concurrently work based on some configuration? (for instance, whether a site feature has been enabled or not?).
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker