Project to customize the small search control in SharePoint 2007

The small search control that is rendered in the default SharePoint pages is a delegate control rendered through master page.  You can find it defined in the master page as follows: image

<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" />

This control is actually available through a feature called "OSearchBasicFeature" located under 12\TEMPLATE\FEATURES.  In the feature elements file (in this feature it's called "SearchArea.xml"), you can see the following:

<Elements xmlns="">
        ControlAssembly="Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
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>

The main class here seems to be Microsoft.SharePoint.Portal.WebControls.SearchBoxEx.  To customize small search, you need to inherit from "SearchBoxEx" class and override "CreateChildControls" method to get your custom small search rendered.  Do not modify any out of the box files as they might lead you into an unsupported scenario.  Instead, following are the simple steps to get the small search control customized:

  1. Create a custom master page by copying the default.master page.  I haven't tested with minimal master as explained here but I am guessing that would work either.

  2. Copy/Paste "OSearchBasicFeature" in the same feature folder with a different name (like mySimpleSearch).

  3. Change the feature ID in the feature.xml file within mySimplerSearch feature.

  4. Change the control ID in the SearchArea.xml file to something like "mySimleSearchcontrol".

  5. Change the class & assembly referenced in the SearchArea.xml file to the control library you created above.

  6. Install & Activate this feature,

  7. Render the custom control you created in the custom master page have and remove "SmallSearchInputBox" control from the master page.

This should do the tricky and you should be able to literally customizing anything within the small search control.

Happy customizing your SharePoint environment - and I really hope this post was helpful!  Look around for things like this in SharePoint as there are plenty of "hacks" to get things done!!!

Comments (11)
  1. bob e says:

    A well written primer on this interesting topic.  Thanks you.

  2. Ted says:

    Is it possible to provide some sample code here? I’m very interested in customizing the rendering of the small search control.

  3. Flannel says:

    I desperately need to make the 2 search boxes stack on top of one another.  I really just need a little <br/> between them.

    If you can show me this I’ll send you $5 donation via Pay Pal.

  4. Sal Romano says:

    Good stuff…

    I will contribute another $15 to Flannel’s $5 offer to bring the total to $20.  

    Sridhar, can you show us how to stack the search boxes please?  

  5. oussar says:

    I wont to do the DDL not visible. but to let the scope to All site by default because i use the facets serach.

    how i can do this?

    Thank u.


  6. amin says:

    Hi Sridhar,

     I’d tried your method but i couldn’t understand your step 5, on how to change the control and assembly.

  7. nareshveergaoni says:

    Hi Sridhar, excellent post. can you please give us a detailed process involved in each step.. thanks a lot.

  8. surfer says:

    Apparently, people are saying good post but all seems to be still confused.

  9. carsten says:

    I want to customize the small search control into two rows. I was searching a few hours through the web with no really helpful results.

    Can anybody help how i can dissolve the two rows problem?

  10. Ahmad says:

    Really nice artical, help me alot, May you be guided.

Comments are closed.

Skip to main content