This topic has not yet been rated - Rate this topic

SearchArea Class

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      Microsoft.SharePoint.WebControls.SearchArea

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SearchArea : SPControl
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Not updated for SP2010?
"The SearchArea class is the backend code file for the searcharea.ascx user control located in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES directory. " $0$0 $0 $0Should point to the 14 Hive for SP2010. Also there does not appear to be a SearchArea.ascx in this folder.$0
SearchArea
Description

The Microsoft.SharePoint.WebControls.SearchArea class inherits from System.Web.UI.UserControl which is the base class for producing orthodox web user controls. The SearchArea class is the backend code file for the searcharea.ascx user control located in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES directory. The search area control is evident as the customary search bar, passing specified search parameters to the search results page. The control is loaded as a delegate control by specifying the control ID, "SearchArea".

The SearchArea class is accountable for querying for particular ToolTip strings from the ViewState if the values are not null. Otherwise, default values are gathered by looking at the SharePoint resource files. The following values are harvested from the ViewState:

SearchImageToolTip – String representation of the ToolTip that is displayed when you hover over the search image in the control

SearchScopeToolTip – String representation of the ToolTip that is displayed when you hover over the scope options in the control

SearchTextToolTip – String representation of the ToolTip that is displayed when you however over the text input in the control

The Usage Scenario

The primary usage of the SearchArea class is internal since it supplies functionality to a shipped user control. The most common location it is brought up is when customizing search controls that are presented on master pages; however this is advisably done by stipulating a distinct ID to a delegate control. 

In the below, I am loading the searcharea user control using Page.LoadControl and performing an orthodox cast since the return type will be of type Control. Once the casting has occurred, the proper object properties are available, and the control is added to the current instance control collection.

C# Code Example

protected override void CreateChildControls()
{
var sa = (SearchArea)Page.LoadControl("~/_controltemplates/searcharea.ascx");
Controls.Add(sa);
base.CreateChildControls();
}

Visual Basic .NET Code Example

Protected Overloads Overrides Sub CreateChildControls()
Dim sa As var = DirectCast(Page.LoadControl("~/_controltemplates/searcharea.ascx"), SearchArea)
Controls.Add(sa)
MyBase.CreateChildControls()
End Sub