How to: Customize a Delegate Control
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.
This example shows the basic process of creating and implementing a delegate control candidate to use for the search box that is displayed on site pages. The control specifies alternate text and an alternate image file to use for the search box in Web sites where you activate the control.
To change the search box icon and alternate text
Create a folder in the \Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES directory that is called NewSearchBox by copying the default \FEATURES\ContentLightup folder.
In the NewSearchBox folder, open the copied Feature.xml file and generate a new GUID for the Feature by running guidgen.exe, which is located in Local_Drive:\Program Files\Microsoft Visual Studio 8\Common7\Tools. Set the Scope attribute to Web so that the Feature is activated at Web site level, as follows:
<?xml version="1.0" encoding="utf-8"?> <Feature Id="9E16894A-998F-4928-97B3-FCB35EAD1C49" Title="Standard User Interface Items" Description="Provides several standard user interface components and links" Version="220.127.116.11" Hidden="TRUE" DefaultResourceFile="core" Scope="Web" xmlns="http://schemas.microsoft.com/sharepoint/"> <ElementManifests> <ElementManifest Location="controls\SearchArea.xml" /> </ElementManifests> </Feature>
In the Controls subfolder included in the first step, modify the SearchArea.xml file so that it references an alternate .ascx file. Also specify alternate text and a Sequence value that is lower than 100, such as the following:
<?xml version="1.0" encoding="utf-8" ?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Control Id="SmallSearchInputBox" Sequence="99" ControlSrc="~/_controltemplates/mySearchArea.ascx"> <Property Name="SearchTextToolTip">Enter text here</Property> <Property Name="SearchImageToolTip">Go!</Property> </Control> </Elements>
In \TEMPLATE\CONTROLTEMPLATES, copy the SearchArea.ascx file, and then rename this copied file mySearchArea.ascx.
On the <img> tag that is located near the end of your copied .ascx file, modify the value of the src attribute to point to an alternate image file. For testing purposes, you can use one of the default image files installed in \TEMPLATE\IMAGES, such as in the following example, which replaces gosearch.gif with FOLDER.GIF.
At a command prompt, navigate to \Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN on the local drive, and type each of the following commands to install the Feature in the deployment, activate the Feature on a specified subsite, and reset Microsoft Internet Information Services (IIS) so that the changes take effect:
stsadm -o installfeature -filename NewSearchBox\Feature.xml stsadm -o activatefeature -filename NewSearchBox\Feature.xml -url http://Server/Site/Subsite iisreset
Navigate to the home page of the specified subsite to see the changes made to the search box.