Wednesday 25 November 2015

Enable SmallSearchbox in Search result page SharePoint

Recently I was given a task to enable Search Bar in Search result page of SharePoint. If you meet such requirement here is the simple solution:

Case 1: You have not configured search service:

In this case your search will open SharePoint default result page: osssearchresults.aspx.

You can find this page in "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS".

Open this page and in "PlaceHolderSearchArea" ContentPlaceHolder add below lines of code:

 <div id="searchInputBox">
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" />                                 
</div>

save the file.

Refresh your search page and you will see the search bar in header section.

Case 2: You have configured Search service:

In this case your search will open pages/result.aspx page for search result.
But we can't add our code in this page. We need to add our block of code in the page layout of this page.

You can find that in "Site settings->masterpages & page layouts -> SearchResult.aspx"
Download this page.

Open this page and in "PlaceHolderSearchArea" ContentPlaceHolder add below lines of code:

 <div id="searchInputBox">
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" />                                 
</div>

save the file.

If you refresh your  page and you get error "Sorry, Something went wrong", Please check this blog.


No comments:

Post a Comment