Archive
How to create a Search Box delegate in SharePoint
Simple but effective…I recently had to change the behaviour of the ‘SmallSearchBox’ control within SharePoint. I wanted to loose the ‘Advanced Search;’ link, the button style and also add some default text into the search box. I found the following method to be the simplest approach.
Standard Search Box
Custom delegate applied
The search box is rendered using a delegate control. If you look at the master page you will see the delegate …
<SharePoint:DelegateControl runat=”server” ControlId=” SmallSearchBox”>
You can alter the behaviour of a delegate control by specifying a delegate with a smaller sequence number. I created the following delegate control within a standard feature…
Feature…
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="
http://schemas.microsoft.com/sharepoint/
">
< Control Id="SmallSearchInputBox" Sequence="10" ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" ControlAssembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"> <
<Property Name="GoImageUrl">/_layouts/images/CFB/go.gif</Property>
<Property Name="GoImageUrlRTL">/_layouts/images/CFB/.gif</Property>
<Property Name="GoImageActiveUrl">/_layouts/images/CFB/go.gif</Property>
<Property Name="GoImageActiveUrlRTL">/_layouts/images/CFB/go.gif</Property>
<Property Name="UseSiteDefaults">true</Property>
<Property Name="FrameType">None</Property>
<Property Name="QueryPromptString">Search…</Property>
<Property Name="DropDownMode">HideDD_useDefaultScope</Property>
</Control>
</Elements>
Note the Sequence=”10” attribute of the Control element. WSS out of the box refers to a sequence number of 100 and MOSS overrides this with a sequence number of 50. So as long as your sequence number is lower than this then your settings will be applied.
The four changes I was concerned was
1. Remove the ‘advanced search’ link which is handled by the ‘ShowAdvancedSearch’ property,
2.Add some default text to the search box which is handcled by the QueryPromptString property
3. Remove the scope drop down field. The DropDownMode property with the enumuration value of HideDD_userDefaultScope sorts that one out.
4. Finally I changed the image to my own go.gif image. I also deployed this within the same feature to a sub directory called CFB within the 12 hive images folder.
For a complete listing of the available properties please refer to the following link on MSDN.

