Wednesday, May 4, 2011

How to configure and customize search text box on SharePoint 2010 site


Today I will describe how to do a simple trick to change your site search box text.  No need to write your own search box or separate feature.  Hence SharePoint 2010 not has given search text box area for freely design with SharePoint designer 2010. We need to over right the feature provided with search box delegate control.
Normally SharePoint 2010 uses.  Feature to render search box. On your V4.master page this search box feature references as delegate control.  following code snap shows the way it’s rendered in V4.masterfile
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox"  Version="4"/>
</asp:ContentPlaceHolder>  
In order to change the search control need to change the properties of search control feature. These feature properties are resided on following locations in the SharePoint 2010 14 hive folder

%14Hive%\Template\Features\OSearchBasicFeature
%14 Hive%\Template\Features\OSearchEnhancedFeature

There for we need to edit both SearchArea.xml files reside in those locations respectively.  Before adding property change, get a copy of both of them in the sense of any mistakes can revert back the original settings back to normal.


Right click on searchArea.xml file and open it in notepad or sharepoint designer 2010. You can see some of the properties already set in this xml file. Here I’m going to change the default text “Search this site..” to “Enter search quarry”
The files are like follows when it opens


In order to change the text you have to over write the property called “QueryPromptString” .  add following code for both files
<Property Name="QueryPromptString">Enter search Quary</Property>  
Likewise we can change some values as listed in MSDN site
After changing the searchArea.xml file save the changes made. In order to trigger this chages in site collection you need to do iisreset.
Now you can see your search text boxes get your provided default text …

Thanks
Radika

No comments:

Post a Comment