Tuesday, May 12, 2009

Customizing Search Box in SharePoint

Scenario:

Customize search box control on your site.

Implementation:

Step 1:
Add the below lines of code to the register control tag section

<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Step 2:
Search box control is found beteen the contentplaceholder

<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">

and would be

<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox"/>

replace the above with the below code and add your fav images around to see a custom search box on your site.

<SPSWC:SearchBoxEx id="SearchButton" RegisterStyles="false" TextBeforeTextBox="" TextBoxWidth="88" GoImageUrl="/_layouts/images/GOSEARCH.GIF" GoImageActiveUrl="/_layouts/images/GOSEARCH.GIF" GoImageUrlRTL="" GoImageActiveUrlRTL="" UseSiteDefaults="true" DropDownMode="HideScopeDD" SuppressWebPartChrome="true" runat="server" WebPart="true" __WebPartId="{0043945F-2D2B-4A02-8510-CED13B6F04DF}"/>

the properties of this control are self explainatory and use them at your requirement.

No comments: