SharePoint 2010 – Set Search Dropdown Mode using C#

When migrating content from SharePoint 2007 to 2010 I needed to write a small console application that would enable the visual upgrade, reset the master page file and also enable the search scope dropdown.     Performing the visual upgrade and resetting the master page was a simple coding exercise.    Enabling the search scope dropdown was a bit of a challenge as it is not as obvious as the others.

To programmatically change a site collections search scope you need to set a value for the  SRCH_SITE_DROPDOWN_MODE key in the AllProperties collection of the root web.

Where siteCollection is a SPSite object:

siteCollection.RootWeb.AllProperties[“SRCH_SITE_DROPDOWN_MODE”] = “ShowDD_DefaultURL”;

Below are the valid values you can use for SRCH_SITE_DROPDOWN_MODE

  • HideScopeDD – Do not show scopes dropdown, and default to target results page
  • ShowDD – Show scopes dropdown
  • ShowDD_DefaultURL – Show, and default to ‘s’ URL
  • ShowDD_DefaultContextual – Show and default to contextual scope
  • ShowDD_NoContextual – Show, do not include contextual scopes
  • ShowDD_NoContextual_DefaultURL – Show, do not include contextual scopes, and default to ‘s’ URL parameter


Hopefully this bit of information saves other developers a bit of search time.

0 thoughts on “SharePoint 2010 – Set Search Dropdown Mode using C#”

  1. Thanks for this post, it was exactly what I needed. You should mention site collections somewhere on the page though as the UI-based way to change this is called “Site Collection Search Dropdown Mode” and when I googled this term with the quotes your post wasn””t in the results.

Leave a Reply