SharePoint MOSS 2007 - using an alternate Search Control

1 minute read

The default search control granted to you by MOSS cant be modified to look or act too much differently than what you see in the example default.master template. The big problem is the Scope. For internet sites, its often best to not show that scope dropdown. Instead, just a simple search box and a go button, then give the option for the user to refine their search within the search results page.
Looking at alternate templates like BlueBand.master shows that there are some alternate search WebParts we can use that are much more configurable ... and they allow us to do away with the anoying scope dropdown. Lets steal the BlueBand.master search. All we need are these two chunks of code: the WebPart registration call and the call to create an instance of the SearchBox component:



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



<div class="search">
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
<SPSWC:SearchBoxEx id="SearchBox" RegisterStyles="false" TextBeforeDropDown="" TextBeforeTextBox="<%$Resources:cms,masterpages_searchbox_label%>" TextBoxWidth="100" GoImageUrl="<% $SPUrl:~sitecollection/Style Library/Images/Search_Arrow.jpg %>"
GoImageUrlRTL="<% $SPUrl:~sitecollection/Style Library/Images/Search_Arrow_RTL.jpg %>" UseSiteDefaults="true" DropDownMode = "HideScopeDD" SuppressWebPartChrome="true" runat="server" WebPart="true" __WebPartId="{F8C1236A-6D6E-4EC4-8587-E8D9A1A57F69}"/>
</asp:ContentPlaceHolder>
</div>

This control comes with the default installed MOSS templates, so it becomes a much better option than compiling your own control, then having to maintain it and worry that a MOSS patch or update might clobber your work.

As a last thought, though the code works, youre still left with styling the control to suit your application look and feel ... which is turning out to be one of the more time consuming parts for me as I"m learning how to develop for MOSS 2007

-.- So I'm thinking the next big hurdle for me will be learning the MOSS method for styling templates.