.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

How to read Contextual Search scopes programmatically?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :C#


I have a requirement where I am trying to code a custom Search control. I am using the code snippet mentioned at http://www.learningsharepoint.com/2010/07/28/programatically-get-search-scopes-for-search-service-application-sharepoint-2010/ to read the Search scopes.

However this gives the Shared search scopes. I am not able to read the contextual search scopes using these API's.

Can anyone help me o how to ready the contextual search scopes "This Site" and "This List" in SharePoint 2010?



View Complete Post

More Related Resource Links

Limiting Search Scopes to Articles, .docs, .xls, etc.

We have a customized site with a number of workarounds, which has necessitated using multiple pages to display data. EG, a contributor might use an "AnnouncementUPLOAD.aspx" page to add data displayed through a Web Part on "Announcement.aspx". I know I can Security Trim at the page and DocLib levels which would carry over into what's revealed by Search, but I'm curious if I can handle this through Scopes. So, if I ran a search for "George Washington", I'd want to return: items in DocLibs (ie Office Documents) items from Announcements, but NOT the full Announcement List. (ie not the http://.../pages/Announcement.aspx page, but the http://.../lists/Announcement.aspx page.) Doable? Thanks!

FASTSearchQueryException encountered when creating FAST Search query scopes in PowerShell

Hi, I made an update to an existing FAST Search query scopes. The updates are on the ExtendedSearchFilter parameter. Since the Set-SPEnterpriseSearchQueryScope PowerShell cmdlet does not work to update the parameter, I removed the existing scopes using Remove-SPEnterpriseSearchQueryScope and created new scopes using the New-SPEnterpriseSearchQueryScope cmdlets. I have noticed that after creating the scopes, I sometimes encounter the "The search request was unable to execute on FAST Search Server" (FASTSearchQueryException) when executing query against the search scope. I am not sure if the exception is related to how the scope objects are disposed after running the Remove-SPEnterpriseSearchQueryScope cmdlet. I tried to look into the Event logs of the FAST search server but I was not able to see the error. I would like to ask the community if the exception can be attributed to the exsiting scopes that were removed then recreated.  Thanks. Jo-an  

How to read checkbox values from programmatically created checkboxes?


I have a form that does a loop to create checkboxes.  Here is the code in the loop:

cbxDrives.Top = TopPosition;
cbxDrives.Left = LeftPosition;
cbxDrives.Text = d.Name; 
CheckBox cbxDrives = new CheckBox();this.Controls.Add(cbxDrives);

This creates multiple check boxes on the form, and this works fine.

However, in the code behind for my button that the user clicks to execute the form, I cannot figure how how to read the values for the checkboxes.  I've tried:

foreach (CheckBox cbxDrive in cbxDrives)


Use centrally defined search scopes in departmental site collections?


I have SSE 2010 installed and functioning.  Seven "shared" scopes have been defined and show as having the expected number of items.   In my departmental web apps I have created Advanced Search and results pages so the users do not have to leave their own web app to do searches across those defined scopes.  Unfortunately the only way I found to make those scopes available in their Advanced Search web part was to "copy" the shared scopes (they display in an "unused scopes" group with no options for use).   The copy allows me to specify that the scope should appear in the Advanced Search web part and/or in the search box dropdown.   Is there anyway to use those "unused" shared scopes without creating a complete copy set of them in every site collection?   Thanks for any assistance you can provide!

Search Scopes - new display group always shows "This site:"


Hello all,

I have created a new scope (Scope A) and everythind works ok. Then I wanted to create a search page (my search page with a search box and search core results) to show only the results from the created scope.

I created a new search display group (Display Group B) and assigned the "Scope A", configured the search box to display the "Display Group B" hidding the scopes drop down list and it didnt work as I wanted as it displayed all the results by default.~

How can I remove the "This site" from my display group, keeping only one scope as the default one?

Thanks for all the help

Best Regards,

André Cunha




creating search scopes in Shared Service Provider


In Shared Service Provider when click on search setting I got error like :"An indexer is not assigned to the Shared Services Provider 'SharedServices2' " .can any one help me out for develop the seearch scopes. and what need to do remove the error.

need help on programmatically adding .pdf file type to File Type list in Search Admin


This is easily done in the GUI but how do I program this?

I looked here - http://msdn.microsoft.com/en-us/library/ms562090(v=office.12).aspx and they just say - Extensions are grouped within an ExtensionCollection object. Use the Create method to specify a new file name extension.

Great but how do I do that - I'm not a coder and I need some pointers

I loaded the sharepoint assemblies:

[System.Reflection.Assembly]::Load("Microsoft.Office.Server.Search, Version=, Culture=neutral,

[System.Reflection.Assembly]::Load("Microsoft.Sharepoint, Version=, Culture=neutral,

[System.Reflection.Assembly]::Load("Microsoft.Office.Server, Version=, Culture=neutral,

Where do I go from here?




Advanced Search Web Part in 2010 does not seem to handle scopes properly


I have configured a page in SP2010 with an advanced scope web part.

I have enabled the scope picker from the "advanced search" scope group and adding a new scope to that group in the site collection settings.

The advanced search web part is targetted to a new results page containing the core results web part.

When I perform a search for string test using one of the scopes that I have selected the results page is called as follows.


No results are rendered.

What I don't quite understand is I thought that the querystring should actually be.


Which when entered manually works.

So it sort of seems that the advanced search web part is rendering the wrong querystring!!

The search centre is enterprise template (not fast) and sharepoint server search is configured not fast search.


Authorization issues while accessing Search Scopes


With reference to the code posted at http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/eddd46a6-899d-4539-bbe0-e0895a667f97

I changed the "Search Context GetContext " from my code and have implemented the code using Service Applications.

I am getting the error

System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.


I have referenced the suggestions posted for the question "http://social.technet.microsoft.com/Forums/en/sharepointsearch/thread/85a35628-8f94-4d31-b085-1b19ef63101b" but I am still running into errors.

My application pool id account,the search administration default accounts are same.The account has also been given db_owner rights for all the search databases.

The crawl is also executed successfully on the central admin.

I am not sure what might be the issue.Any help would be greatly appreciated.





Search Server Express scopes not including any items

I installed Search Server Express 2010 on a SharePoint Foundation farm.  It's a pretty basic install - I let the Local SharePoint sites crawler finish and it found about 200 items.  When I look at the All Sites scope, however, the item count is zero.  Even if I set the scope update to on-demand it doesn't seem to want to pick up items.  Any thoughts on how to troubleshoot scopes?

How to change the URL in Search Settings to use Custom Scopes.



How can I change programmatically the URL for the Custom Scopes?

It's in the Administration -> "Search Settings".



Quck Search Box and Search Scopes


I work in SharePoint 2007. There is a quick search box in the top right hand corner of the screen. I have added a search scope in site settings. This search scope shows up now in the drop-down in this search box. But when I enter a search term and click on the search button, it takes me the Advanced Search page that I created. How do I change this search scope to take me to results page instead of search page and how can I make this search work so it would bring me some results? Do I need to do anything else besides changing/addind search scopes in site settings?

Thank you very much in advance.

How to read Search index using SQL



Where does the search index data get stored in sharepoint ? Is it in the index file location or in the SQL database ? Is it possible to read the index data using SQL queries ?

Sharepoint content search programmatically



I am trying to develop a web part that will search in a document library based on different parameters. Now I want to have search based on different columns of document library as well as the content of the files being uploaded in the document library.

What is the best way to accomplish this ? Are there any good articles describing how to perform sharepoint search programmatically ?

Thanks, Tejas

"Object reference not set to an instance of an object. " in Search scopes



      I want to create new Search scope so I have  click on Search scopes option in Site Collection Administrator than error message is occour as followe

Object reference not set to an instance of an object.   at Microsoft.SharePoint.Portal.Search.Admin.Pages.SearchAdminPageBase.ErrorHandler(Object sender, EventArgs e)
   at System.Web.UI.TemplateControl.OnError(EventArgs e)
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP._layouts_viewscopes_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\28d4544f\99dd74e8\App_Web_viewscopes.aspx.2a428413.s6avjyxg.0.cs:line 0

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend