Replace Delegate Control – SmallSearchInputBox

In this previous post, I detailed how to ‘customise’ the OOTB SharePoint Search Box control – by including delegate properties.   This works for MOST scenarios – but sometimes, you need more control (no pun intended).

For other scenarios – or if you can’t get it working/sand-boxed/etc – you can simply REPLACE the Delegate – with the actual SearchBoxEx control – within the Master Page.

To do this – you need to do the following :

  • Open the Master Page (eg. v4.master) – in SharePoint Designer – or Visual Studio
  • Add the following to the top of the page – to allow you to reference the Search Control :

<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Then, you can replace the delegate control :

  • Do a search (CTRL-F) for “SmallSearchInputBox
  • Replace the following :

<SharePoint:DelegateControl ID="DelegateControl3" runat="server" ControlId="SmallSearchInputBox" Version="4"/>

  • With this markup :

<SharePointWebControls:SearchBoxEx ID="SmallSearchBox" runat="server" ShowAdvancedSearch="false" QueryPromptString="Enter Search Term…" DropDownMode="HideDD_NoScope" SearchResultPageURL="/_layouts/osssearchresults.aspx" ScopeDisplayGroupName="" FrameType="None" DisplaySubmittedSearch="false" />

Once you have this in place, you can change any specific property for “SearchBoxEx” :

  • Eg. QueryPromptString = Enter Search Term

See MSDN for a list of properties you can change/update – for the SearchBoxEx control.

Lastly – make sure you save/check-in the updated Master Page.

It should look identical – but you can now change the properties within the Master Page itself.

Good luck – this approach certainly worked for me !

Smile

Advertisements

5 thoughts on “Replace Delegate Control – SmallSearchInputBox

  1. We stumble over a strange behaviour of our custom master page when using this approach. The SearchBox worked well, but when we tried to delete a field from any list while the master page is active, we got an “Invalid ViewState” exception.

    This behaviour is also described in http://social.technet.microsoft.com/Forums/en-NZ/sharepoint2010customization/thread/021c6c2d-4bdb-4e76-a48a-a51502fc809a .

    In our case the SearchBoxEx control caused the exception, because after removing it from the master page we were able to delete fields again.

    Like

  2. But the problem is that the Advance search URL is absolute and i have more than 20 web app which have there own search center….Please let me know the solution in case of changing advance serch link…
    Thanks in advance…

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s