It turns out that in 2013, there is a new search control that allows you to create a search box without using Visual Studio and you can do it in your master page. I found the line near the top of the master page that begins with:
<%@Register TagPrefix="SearchWC"
This line has the new Search control in it and allows for some nice customizing right in the declaration itself. So to create an "Employee Lookup" control I did this:
<SearchWC:SearchBoxScriptWebPart ID="EmployeeSearch" UseSiteCollectionSettings="false" InitialPrompt="Employee Lookup..." ShowPeopleNameSuggestions="true" ResultsPageAddress="/searchcenter/Pages/peopleresults.aspx" EmitStyleReference="false" ShowQuerySuggestions="true" ChromeType="None" UseSharedSettings="false" TryInplaceQuery="false" ServerInitialRender="true" runat="server" />
This creates a nice search box that goes directly to the desired page! It is clean and neat and does not take extra effort to create. It uses the same styles so can be styled however you want. The key options here are UseSharedSettings which must be false as well as UseSiteCollectionSettings.
The options available can be found on MSDN here
You can also extend this further if you did want to play with some templates and create a whole new experience. The templates are in the Master Page Gallery in the Display Templates/Search folder. The default template is called "Control_SearchBox_Compact" and there are 2 files (.js and .html) for each template. The ServerInitialRender property must be set to false if you want to override the templates!
I hope you have found this useful and please post any feedback you have!
Dan
Brilliant post! I tried changing resultspage and couldn't understand why it didnt work untill I saw here that UseSiteCollectionSettings="false" was missing in my snippet. Thank you
ReplyDeleteI Love you man, thanks a lot
ReplyDeleteHi
ReplyDeleteHow can i hide this search box on my settings page? I am suing site master page as system master page and search box is available on all pages.
Thank you so much !!!
ReplyDeleteYou save my day !!
Alex From FRANCE !!
Hi,
ReplyDeleteI found this code in Searchresults.aspx and not in seattle.master/html.
Can you please advice the right place to place the above code?
Thanks,
Hi,
ReplyDeleteI meant -"<%@Register TagPrefix="SearchWC"" found in searchresults.aspx and not in seattle.master.
Priyanka,
DeleteUnfortunately I don't have a copy of seatle.master to check at the moment. However, it is available in several master pages and the entire declaration can be copied. The main thing is that you need to be sure that you have the declaration in the master page at the top with all the others.
Dan