How to: Use the Search Box as a Web Control
The Search Box is a highly configurable Web Part, which, as any Web Part, can also be used as an HTML control. You can use each property of the Search Box Web Part as an attribute on the Search Box Web control. This topic demonstrates how to implement the Search Box as a Web control, and also lists the properties that you can configure to customize your search experience.
To add the Search Box Web control
In the .aspx file for your Web page or Web form, add the appropriate register directive for the SPSWC control tag prefix.
For released builds, use the following directive.
For builds you are using for debugging, use the following directive.
In the same .aspx file for your Web page or Web form, add the Search Box control. The following simple example works in the same manner as the default Search Box on the Enterprise Search in Microsoft Office SharePoint Server 2007 search page.
<SPSWC:SearchBoxEx id="SearchBox" runat="server" GoImageUrl="/_layouts/images/gosearch.gif" GoImageUrlRTL="/_layouts/images/gosearch.gif" DropdownModeEx=ShowDD UseSiteDefaults="true" FrameType="None" />
The drop down list for this Search Box displays the contextual scope and the authored scope. The list shows by default the scope specified for the Search Dropdown display group. This example also uses the default "Go" image. See SearchBoxEx Properties (Microsoft.SharePoint.Portal.WebControls) for all of the properties and valid values that you can use when configuring your Search Box.
The following example code shows how to customize the Search Box to display an Advanced Search link and customized display text that appears before the drop down list and the text input box. You must also include a value for
AdvancedSearchPageURL so that The Advanced Search link can appear. This sample uses the register directive for released builds.
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <SPSWC:SearchBoxEx id="SearchBox" runat="server" GoImageUrl="/_layouts/images/gosearch.gif" GoImageUrlRTL="/_layouts/images/gosearch.gif" DropdownModeEx=ShowDD TextBeforeDropDown = "Search" TextBeforeTextBox = "For" ShowAdvancedSearch = true AdvancedSearchPageURL = "yourpage.aspx" UseSiteDefaults="true" FrameType="None" />