5,550,131 members and growing! (19,136 online)
Email Password   helpLost your password?
Enterprise Systems » SharePoint Server » General     Intermediate License: The Code Project Open License (CPOL)

Search User Controls for Microsoft Office SharePoint Server (MOSS)

By Stephen Huen

A set of user controls to provide Microsoft Office SharePoint Server (MOSS) search functionality
C#, Windows, .NET 2.0, .NET, ASP.NET, Visual Studio, VS2005, Dev

Posted: 22 Mar 2007
Updated: 29 Aug 2008
Views: 36,072
Bookmarked: 19 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
5 votes for this Article.
Popularity: 3.34 Rating: 4.78 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
1 vote, 20.0%
3
0 votes, 0.0%
4
4 votes, 80.0%
5
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



Occupation: Web Developer
Company: Questech Systems
Location: Canada Canada

Other popular SharePoint Server articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 47 (Total in Forum: 47) (Refresh)FirstPrevNext
Subject  Author Date 
Questionproblem with PATH property in extended sitememberbilalfastian11:14 25 Aug '08  
AnswerRe: problem with PATH property in extended sitememberStephen Huen10:28 26 Aug '08  
GeneralHow to set Public PropertiesmemberBharat Chopra6:03 28 Apr '08  
GeneralRe: How to set Public PropertiesmemberStephen Huen17:22 29 Apr '08  
GeneralHitHighLightedSummarymemberSearchDeveloper5:24 29 Jan '08  
Generalows_name(Text)memberSearchDeveloper9:15 15 Jan '08  
GeneralSearchmemberSearchDeveloper5:30 12 Dec '07  
GeneralScopesmemberSearchDeveloper5:44 4 Dec '07  
GeneralHelp in SearchmemberSearchDeveloper11:43 29 Nov '07  
GeneralRe: Help in SearchmemberStephen Huen15:00 29 Nov '07  
GeneralRe: Help in SearchmemberSearchDeveloper12:34 30 Nov '07  
GeneralRegarding PictureThumbNailURLmemberSearchDeveloper10:28 28 Nov '07  
GeneralRe: Regarding PictureThumbNailURLmemberStephen Huen12:40 28 Nov '07  
QuestionQuestion on SearchmemberVvenkatesan4:51 28 Nov '07  
AnswerRe: Question on SearchmemberStephen Huen11:36 28 Nov '07  
GeneralRe: Question on SearchmemberVvenkatesan11:38 28 Nov '07  
GeneralRegarding ScopememberSearchDeveloper7:05 27 Nov '07  
GeneralRe: Regarding ScopememberStephen Huen9:41 27 Nov '07  
GeneralAdvance SearchmemberVvenkatesan9:55 26 Nov '07  
Generalwebpart for custom search using keyword query class(creating a search restriction)membershareknk0:32 20 Nov '07  
GeneralRegarding SearchmemberSearchDeveloper11:57 13 Nov '07  
GeneralRe: Regarding SearchmemberStephen Huen22:34 13 Nov '07  
GeneralRe: Regarding SearchmemberSearchDeveloper10:44 14 Nov '07  
GeneralRe: Regarding SearchmemberSearchDeveloper11:29 14 Nov '07  
GeneralRe: Regarding SearchmemberStephen Huen12:01 14 Nov '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 29 Aug 2008
Editor: Sean Ewington
Copyright 2007 by Stephen Huen
Everything else Copyright © CodeProject, 1999-2008
Web15 | Advertise on the Code Project