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