Set Default Value for Search Input Box in SharePoint 2010

There are multiple ways to set the default value in small search input box depending of the scope. Approaches are described below:

Farm Level

If you want to change the default text in Farm level follow the steps,

  1. Open the file in notepad.

    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\OSearchBasicFeature\SearchArea.xml

  2. Add the below property within the <Control> node.
    1. <Property Name="QueryPromptString"> [Your Default Search Text] </Property>  
    Here [Your Default Search Text] is the text you want to show in the search box.

  3. Open the file in notepad.

    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\OSearchEnhancedFeature\SearchArea.xml

  4. Add the below property within the <Control> node.
    1. <Property Name="QueryPromptString"> [Your Default Search Text] </Property>  
    Here [Your Default Search Text] is the text you want to show in the search box.

Web Application/Site Collection/Site Level

If you want to change the default text for Web Application/Site Collection/Site (Web) level follow the below steps,

  1. Create a blank SharePoint project and add an “Empty Element” within it.

  2. Add the below code within the <Elements> node.
    1. <Control  
    2. Id="SmallSearchInputBox"  
    3. Sequence="10"  
    4. ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx"ControlAssembly="Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutralPublicKeyToken=71e9bce111e9429c">  
    5.     <Property Name="GoImageUrl">/_layouts/images/gosearch15.png</Property>  
    6.     <Property Name="GoImageUrlRTL">/_layouts/images/gosearchrtl15.png</Property>  
    7.     <Property Name="GoImageActiveUrl">/_layouts/images/gosearchhover15.png</Property>  
    8.     <Property Name="GoImageActiveUrlRTL">/_layouts/images/gosearchrtlhover15.png</Property>  
    9.     <Property Name="DropDownMode">ShowDD</Property>  
    10.     <Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx</Property>  
    11.     <Property Name="ScopeDisplayGroupName"></Property>  
    12.     <Property Name="FrameType">None</Property>  
    13.     <Property Name="QueryPromptString">[Your Default Search Text]</Property>  
    14. </Control>  
    Note: sequence number must be smaller than the default one (default is set to 50).

  3. Define the scope of the feature which deploy this Empty Element. Depending on the feature’s scope the Default Text would set.
Ebook Download
View all
Learn
View all