1

I've got some code that loops through webparts on a page looking for an Advanced Search box in order to change some properties. Very simple stuff, essentially:

if (webpart is AdvancedSearchBox) {
  do stuff;
}

I have seen this class referenced on blogs in code pertaining to SharePoint 2010 (http://weblogs.asp.net/spano/archive/2012/07/20/customizing-a-sharepoint-2010-search-center.aspx for example), but I can't for the life of me find the class itself.

The only official reference I can find refers to 2007 - http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.webcontrols.advancedsearchbox(v=office.12).aspx, and no matter what assemblies I include, Intellisense just does not recognise it.

I hope I'm missing something obvious - does anyone know where this class is included, or whether it's deprecated? The web part itself is already in use in our solution, so it definitely exists somewhere. Many thanks in advance!

0

The assembly you are looking for is "Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

See webpart definition:

<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Advanced Search Box</Title>
  <FrameType>None</FrameType>
  <Description>Displays parameterized search options based on properties and combinations of words.</Description>
  <FrameState>Normal</FrameState>
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <IsVisible>true</IsVisible>
  <Assembly>Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
  <TypeName>Microsoft.Office.Server.Search.WebControls.AdvancedSearchBox</TypeName>
  <TextQuerySectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" _locID="WP_ASB_TextSectionLabel">Find documents that have...</TextQuerySectionLabelText>
  <ShowAndQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowAndQueryTextBox>
  <AndQueryTextBoxLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
  <ShowPhraseQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowPhraseQueryTextBox>
  <PhraseQueryTextBoxLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
  <ShowOrQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowOrQueryTextBox>
  <OrQueryTextBoxLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
  <ShowNotQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowNotQueryTextBox>
  <NotQueryTextBoxLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
  <ScopeSectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" _locID="WP_ASB_ScopeSectionLabel">Narrow the search...</ScopeSectionLabelText>
  <ScopeLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
  <ShowLanguageOptions xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowLanguageOptions>
  <LanguagesLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
  <ShowResultTypePicker xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowResultTypePicker>
  <ResultTypeLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
  <ShowPropertiesSection xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowPropertiesSection>
  <PropertiesSectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" _locID="WP_ASB_PropertiesSectionLabel">Add property restrictions...</PropertiesSectionLabelText>
</WebPart>
| improve this answer | |
  • Thanks for the quick reply Raymond! Unfortunately I already had that assembly included, and the AdvancedSearchBox class doesn't seem to exist within it. Has it been removed or made obsolete? – Vassal Aug 7 '13 at 10:25
  • May be you can do that like this:if(webpart.GetType().FullName=="Microsoft.Office.Server.Search.WebControls.AdvancedSearchBox"){//do stuff} – Raymond Aug 8 '13 at 1:04
0

Solved it. What was needed in order to use the class was all of the following:

  • Microsoft.office.server.search.dll added as reference
  • Both of the following using directives:
    • using Microsoft.Office.Server.Search
    • using Microsoft.Office.Server.Search.WebControls
  • And a Visual Studio restart

I think it was the last point that stumped me - until the restart, VS wasn't recognising the class name at all.

Thanks for your help Raymond, and additional thanks to Pradip T on Technet. http://social.technet.microsoft.com/Forums/sharepoint/en-US/295b0962-0cdf-41e4-96c9-d07876982c4d/sharepoint-2010-advancedsearchbox-class-or-similar

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.