Share via


How to create a HTML search box for SharePoint search

Search in Microsoft Windows SharePoint Services supports URL syntax. You can encode search keywords and parameters in URL and post directly to the search page.

For more information about SharePoint search URL syntax, please refer to: https://msdn2.microsoft.com/en-us/library/aa979736.aspx.

Following HTML code snippet would provide a simple HTML search box that links to a SharePoint search result page. You need to replace <SharePoint-search-results-page-URL> with your SharePoint search page.

<form method="get" action=" <SharePoint-search-results-page-URL> ">

<input name="k" type="text" /><input name="Search" type="submit" value="Search" />

</form>

You can add sorting options to the search box using following HTML code snippet:

<form method="get" action=" <SharePoint-search-results-page-URL> ">

<input name="k" type="text" /><input name="Search" type="submit" value="Search" />

<input name="v" type="radio" checked="checked" value="relevance" />Sort by relevance

<input name="v" type="radio" value="date" />Sort by date

</form>

 

Zewei Song, Ph.D.

MCPD, MCTS: .NET 3.5, MOSS AppDev, Configuration

Enterprise Services, Microsoft Corporation

Comments

  • Anonymous
    March 08, 2011
    First of all, thanks for the tips. I have used a form web part and paste the first part of your code in (without the options of search) However it doesn't work... What I did was replacing <SharePoint-search-results-page-URL> with the search result page url... Could you please advise how i can solve this problem? Many thanks.

  • Anonymous
    May 20, 2011
    thnkz