Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have a custom webpart listen to default SharePoint search box?

SharePoint has a search box by default at the top of the Portal. I want my WebPart to be able to intercept that search and provide search results. Is this possible, and if so any tips or links on how to do this?

like image 864
catbelly Avatar asked Jan 30 '26 04:01

catbelly


2 Answers

On the result page, just remove the Core Search Results webpart and add your webpart instead.
In your webpart, get the query from the querystring (argument k for keywords and s for scope).

like image 126
Nico Avatar answered Jan 31 '26 20:01

Nico


You actually have several options here. You can replace the CSR Web Part as Nico suggests. But you could also just change the target URL on your search scopes to point to another ASPX page where you have your own search result Web Part. Change the target URL by going to Site Settings -> Search Scopes. The target URL on Shared Scopes must, however, be edited at the level of the Shared Services Provider.

Finally, it is also possible to completely replace the search box on all pages. This is fairly simple as you just need to install a SharePoint Feature that instructs the underlying delegate control to show your search box instead of the SharePoint one. Deactivate the feature again and all pages in the site collection reverts to the original search box again. Clever eh? But you should of course only go for this solution if you fundamentally need to extend the behavior or layout of the search box.

like image 28
Lars Fastrup Avatar answered Jan 31 '26 20:01

Lars Fastrup



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!