Click here to Skip to main content
Click here to Skip to main content

Search User Controls for Microsoft Office SharePoint Server (MOSS)

By , 29 Aug 2008
 
Screenshot - sample.gif

Introduction

Although the out-of-the-box search Web parts provided by Microsoft Office SharePoint Server (MOSS) 2007 are very customizable, there are situations where you may want to develop your search interface to hook into MOSS. This download consists of a Search Box user control and a Search Results user control. The Search Results user control uses the new FullTextSqlQuery API to return the search results. As user controls (I might add a Web part version later), the look and feel are very easy to customize.

Description

The Search Box user control SearchBox.ascx has several public properties:

  • SearchResultsUrl - URL of the search results page. Default is the current page.
  • DefaultSearchScope - Default search scope. Default is All Sites.
  • SearchScopes - A comma delimited list of search scopes. If provided, they will be rendered in a dropdown list for user to limit the scope of the search.

The Search Results user control SearchResults.ascx has several public properties:

  • ResultFields - A comma delimited list of result fields. Default is WorkId, Rank, Title, Author, Size, Path, Description, Write, SiteName, CollapsingStatus, HitHighlightedSummary, HitHighlightedProperties, ContentClass, IsDocument, PictureThumbnailURL.
  • RowLimit - The number of search result items returned per page. Default is 10.
  • HitHighlightedTag - The HTML tag (without the enclosing angled brackets) to highlight the search words when rendering the result field HitHighlightedSummary. Default is b for bold.

Installation

The sample Visual Studio 2005 SP1 solution includes all the support files you need to build and deploy the user controls, minus strong name key files (*.snk). (The supplied Visual Studio 2005 solution contains Web Application projects supported only by SP1 or after.) It contains two projects: Deployment and Office.Server.Search. The Office.Server.Search project contains source codes for the user controls. The Deployment project contains a pre-build script to aggregate all the files needed for deployment. It contains a Solution directory where a WSP file is generated and deployed by a post-build script.

This structure of Visual Studio solution and projects is designed to be scalable to full blown MOSS/WSS development and deployment. You could add additional projects like SharePoint for WSS/MOSS development or SharePoint.Publishing for MOSS Publishing development. Within your projects, you could have other custom components like Web controls, Web parts, custom fields, feature receivers etc.

Of course you can install the user controls as is without further customization. Using stsadm, install the solution file QuestechSolution.wsp in \Deployments\Solution\:

stsadm -o addsolution -filename QuestechSolution.wsp

Then go to SharePoint Central Administration/Operations/Global Configuration-Solution Management and deploy the solution to selected Web applications. To insert the user controls to a page, modify the appropriate master page or page layout as follows:

...
<%@ Register TagPrefix="Questech" TagName="SearchBox"
      src="~/_controltemplates/Questech/SearchBox.ascx" %>

<%@ Register TagPrefix="Questech" TagName="SearchResults"
      src="~/_controltemplates/Questech/SearchResults.ascx" %>
...
...
<Questech:SearchBox id="SearchBox" runat="server" />

 ... 
<Questech:SearchResults id="SearchResults" runat="server" />
...

References

  1. Enterprise Search Query Object Model Overview
  2. Custom Enterprise Search Web Part Code
  3. Creating a Web part to explicitly search custom columns in MOSS 2007 - Part 1 and 2
  4. MOSS - Search Scopes

History

  • V1.2 - 2008.08.26 - Added support for sites run under extended web applications
  • V1.1 - 2008.04.22
    • Included sample Visual Studio 2005 solution for compiling and deploying the user controls
    • Updated installation instructions
  • V1.0 - 2007.03.22 - Base

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Stephen Huen
Web Developer Questech Systems
Canada Canada
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionIts not workingmemberkarthikmandadi@gmail.com25 Jul '12 - 20:50 
GeneralCustom search in WSS 3.0membersmasher91 Aug '09 - 17:16 
Questionproblem with PATH property in extended sitememberbilalfastian25 Aug '08 - 10:14 
I used these controls on my site. They worked perfect
 
After that I extended my site for an extranet zone.
 
The problem is that the PATH property still returns the original site URL and not the extended site URL. How can I get the extranet site URL in PATH property? Is there any other property which I can use to get the file path.
 
Urgent help will be highly appreciated.
 
regards
Bilal Ahmad
AnswerRe: problem with PATH property in extended sitememberStephen Huen26 Aug '08 - 9:28 
QuestionHow to set Public PropertiesmemberBharat Chopra28 Apr '08 - 5:03 
AnswerRe: How to set Public PropertiesmemberStephen Huen29 Apr '08 - 16:22 
GeneralHitHighLightedSummarymemberSearchDeveloper29 Jan '08 - 4:24 
Generalows_name(Text)memberSearchDeveloper15 Jan '08 - 8:15 
GeneralSearchmemberSearchDeveloper12 Dec '07 - 4:30 
GeneralScopesmemberSearchDeveloper4 Dec '07 - 4:44 
GeneralHelp in SearchmemberSearchDeveloper29 Nov '07 - 10:43 
GeneralRe: Help in SearchmemberStephen Huen29 Nov '07 - 14:00 
GeneralRe: Help in SearchmemberSearchDeveloper30 Nov '07 - 11:34 
GeneralRegarding PictureThumbNailURLmemberSearchDeveloper28 Nov '07 - 9:28 
GeneralRe: Regarding PictureThumbNailURLmemberStephen Huen28 Nov '07 - 11:40 
QuestionQuestion on SearchmemberVvenkatesan28 Nov '07 - 3:51 
AnswerRe: Question on SearchmemberStephen Huen28 Nov '07 - 10:36 
GeneralRe: Question on SearchmemberVvenkatesan28 Nov '07 - 10:38 
GeneralRegarding ScopememberSearchDeveloper27 Nov '07 - 6:05 
GeneralRe: Regarding ScopememberStephen Huen27 Nov '07 - 8:41 
GeneralAdvance SearchmemberVvenkatesan26 Nov '07 - 8:55 
Generalwebpart for custom search using keyword query class(creating a search restriction)membershareknk19 Nov '07 - 23:32 
GeneralRegarding SearchmemberSearchDeveloper13 Nov '07 - 10:57 
GeneralRe: Regarding SearchmemberStephen Huen13 Nov '07 - 21:34 
GeneralRe: Regarding SearchmemberSearchDeveloper14 Nov '07 - 9:44 
GeneralRe: Regarding SearchmemberSearchDeveloper14 Nov '07 - 10:29 
GeneralRe: Regarding SearchmemberStephen Huen14 Nov '07 - 11:01 
GeneralRe: Regarding SearchmemberSearchDeveloper14 Nov '07 - 22:08 
GeneralRe: Regarding SearchmemberStephen Huen15 Nov '07 - 7:24 
GeneralRe: Regarding SearchmemberSearchDeveloper19 Nov '07 - 5:21 
GeneralRe: Regarding SearchmemberSearchDeveloper19 Nov '07 - 11:15 
QuestionHow to customise so that the above behaves same as MOSS SearchmemberSearchDeveloper8 Nov '07 - 7:14 
AnswerRe: How to customise so that the above behaves same as MOSS SearchmemberStephen Huen8 Nov '07 - 13:17 
GeneralRe: How to customise so that the above behaves same as MOSS SearchmemberSearchDeveloper9 Nov '07 - 5:30 
GeneralRe: How to customise so that the above behaves same as MOSS SearchmemberSearchDeveloper13 Nov '07 - 10:36 
AnswerRe: How to customise so that the above behaves same as MOSS SearchmemberSearchDeveloper13 Nov '07 - 10:51 
GeneralError : GetScopeIDmemberiantbaker6 May '07 - 13:05 
GeneralRe: Error : GetScopeIDmemberStephen Huen6 May '07 - 17:24 
GeneralCa n it do wild card search on people searchmemberVinay Yeluri18 Apr '07 - 10:18 
GeneralRe: Ca n it do wild card search on people searchmemberKrishna Hari27 Sep '07 - 0:21 
Generalcould not load the assemblymembermhammad412 Apr '07 - 0:56 
GeneralRe: could not load the assemblymemberStephen Huen12 Apr '07 - 7:05 
GeneralRe: could not load the assembly [modified]membermhammad412 Apr '07 - 20:28 
GeneralRe: could not load the assemblymemberStephen Huen13 Apr '07 - 14:50 
GeneralRe: could not load the assemblymembermhammad416 Apr '07 - 3:05 
GeneralRe: could not load the assemblymemberStephen Huen18 Apr '07 - 12:33 
GeneralRe: could not load the assemblymemberSearchDeveloper9 Nov '07 - 5:58 
QuestionHow do I see this search controlmemberBplGuy11 Apr '07 - 21:15 
AnswerRe: How do I see this search controlmemberStephen Huen12 Apr '07 - 7:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 29 Aug 2008
Article Copyright 2007 by Stephen Huen
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid