Share via


How to: Override a Default Control Template

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

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" >
  <Template>
    <SharePoint:InformationBar />
    <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&nbsp;" >
      <Template_RightButtons>
        <SharePoint:SaveButton TabIndex=1 />
        <SharePoint:GoBackButton />
      </Template_RightButtons>
    </wssuc:ToolBar>
    <SharePoint:FormToolBar />
    <SharePoint:FormComponent TemplateName="DocumentLibraryFormCore" />
    <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.