in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

This Blog

Syndication

Mirrored Blogs

Customize SearchBoxEx

A external company made a design for a Internet facing website, in the design the search control was made up in to rows. So my first idea was to create a new controltemplate for the SmallSearchInputBox, but then I realized that in moss the search-control isn't a controltemplate anymore (in WSS it is). The searchbox in MOSS is a control called SearchBoxEx, and this has some properties for the layout of the control. But is always renders the output as a table with 1 row, so my problem was how to render is in 2 rows using divs. Google didn't provide me with an answer, so is started coding myself (I don't want to create a new control with all logic,  I just want reuse all the logic of SearchBoxEx and provide new render logic).

I finally found a wayto do this, I just create an new control that inherits from SearchBoxEx. My custom look-and-feel can be done used an override of the CreateChildControls:

Find controls

I first call the base.CreateChildControls to have SearchBoxEx create all the controls based on the properties set. Then I start looping through the tablecells to find the Go-button, the other controls (textbox & dropdownlist) are available as protected members. After the go-button has been found, I set the table to invisible. Now that I have a reference to the controls I can start building my own look-and-feel:

build new layout

Download source: searchbox.cs

Read the complete post at http://www.lankamp.net/post/2007/10/Customize-SearchBoxEx.aspx


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts