Customizing OOB Small Search Input Box

Posted by in SharePoint category on for Intermediate level | Points: 150 | Views : 20862 red flag

This article explains delegate control and also explains how to customize OOB small search box without more efforts.

Customizing OOB Small Search Input Box

Here, I will explain MOSS OOB SmallSearchInputBox control and then will explain how to customize this box.
SharePoint provides OOB search delegate control.

What is MOSS OOB SmakkSearchInputBox control?

SharePoint comes with the Out Of Box (OOB) control for the search the site content. This control renders on all the default pages of SharePoint using delegate control. This control is rendered using Default.master master page which is located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL (assuming C drive is the installation drive for MOSS).

What is Delegate controls in SharePoint?

1. Delegate controls in SharePoint are used to add the controls (User control as well as Server controls) on the SharePoint page, without any modification in SharePoint page.

2.These controls specify the features which control will be added.
   For ex: Default master page includes the search box to include the search box it uses the delegate control as    
   <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" />
    Where ControlId : Control which is to be added

3. When we add above code, it creates the instance of delegate control

4. Delegate control uses Features to load the control specified in ConttolId attribute.

5. So for the SmallSearchInputBox control, when we install SharePoint, two Features are installed 
and OSearchEnahancedFeature.
    For ex. OSearchBasicFeature is looks like as follows

<Feature  Id="BC29E863-AE07-4674-BD83-2C6D0AA5623F" 
ReceiverAssembly="Microsoft.Office.Server.Search, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

<ElementManifest Location="searcharea.xml"/>
And searcharea.xml file looks like

<Elements xmlns=""> 
<Control Id="SmallSearchInputBox” Sequence="50"
ControlAssembly="Microsoft.SharePoint.Portal, Version=, Culture=neutral,
<Property Name="GoImageUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageUrlRTL">/_layouts/images/goRTL.gif </Property>
<Property Name="GoImageActiveUrl">/_layouts/images/gosearch.gif </Property>
<Property Name="GoImageActiveUrlRTL">/_layouts/images/goRTL.gif </Property>
<Property Name="DropDownMode">ShowDD</Property>
<Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx </Property>
<Property Name="ScopeDisplayGroupName"></Property>
<Property Name="FrameType">None</Property>

6. So here if you at searcharea.xml, there <Control> element is with the same Id which is specified in ControlId 
    attribute in delegate element in default.master page

7. Here one more important attribute is “Sequence”. Value of sequence element must be the lower than value of
    Sequence element of the same control. This is important to override existing delegate control. Because delegate
    control checks the list of controls from Features and if multiple controls found with same ControlId then it
    pickups the control with lowest sequence number.

8. So here conclusion is delegate control uses Feature to add the respective control on the sharepoint page
   and uses Sequence number to load the particular control if multiple same controls are available.

Now back to our main point to customizing the OOB smallsearchinput box, default OOB smallsearchinputbox having the following elements:

1. Scope Drop-Down
2. Text Box for search keyword
3.  Search Button
4.  Advanced Search Link(in publishing sites)
and we have requirement is like

1.  Hide the scope drop-down
2.  Hide the Advanced Search Link
3.  When we click on Go button, page should be redirected to our custom search page  

Now to customize this OOB control, we will use following steps:
1. Copy the OOB feature, rename it something like “CustomSmallSearchInputBox”

2. Change the GUID of feature. (In VS, Tools >> Create GUID) also change the Title and Description element.

3. We will keep the values of Receiverassembly and ReceiverClass elements, since we are overriding the OOB small
   search input box.

4. Now the important changes in searcharea.xml file are:

a.  Lower Value of Sequence attribute of <Control> element so that OOB search control will be overridden to ours one

b. Change the properties values as per our requirement, For example:
      i. To hide the scope drop-down : -
         <property Name="DropDownMode"> HideScopeDD </ Property>
      ii. To hide the advanced search link:-
          <Property Name="ShowAdvancedSearch">false</Property>

      iii. To redirect search result at our custom page: - our custom page is Search.aspx in Pages library
           so the actual property becomes as
          <Property Name="SearchResultPageURL">/pages/search.aspx </Property> 

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Prasham Sabadra
Member Level:
Member Status: Member
Member Since: 7/30/2010 3:02:30 AM
Country: India
Thanks and Best Regards Prasham
Hi, I am very passionate about the latest technologies and software development. MCTS for SharePoint 2010, MCTS in WSS 3.0 and MCP for .NET Framework 2.0. Also keen interested in Microsoft SharePoint technology.

Login to vote for this post.

Comments or Responses

Posted by: Raja on: 11/6/2010 | Points: 25
Good effort, keep it up!

Login to post response

Comment using Facebook(Author doesn't get notification)