New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

Telerik RadSearchBox for ASP.NET AJAX provides the user the ability to write text in an input field with an optional autocomplete functionality.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
[EmbeddedSkin("SearchBox", typeof(RadSearchBox))]
[EmbeddedSkin("SearchBox", "Default", typeof(RadSearchBox))]
[RequiredCss("Telerik.Web.UI.Skins.Common.fonticons.css", RenderMode.Lightweight, typeof(RadSearchBox))]
[RequiredCss("Telerik.Web.UI.Skins.Common.MaterialRipple.css", RenderMode.Lightweight, typeof(RadButton))]
[RequiredScript(typeof(jQueryPlugins), 1)]
[RequiredScript(typeof(DropDown), 2)]
[RequiredScript(typeof(ChangeLog), 3)]
[RequiredScript(typeof(MaterialRipple))]
[ClientScriptResource("Telerik.Web.UI.RadSearchBox", "Telerik.Web.UI.SearchBox.RadSearchBoxScripts.js")]
[TelerikToolboxCategory("Data Editing")]
[ToolboxBitmap(typeof(RadSearchBox), "Toolbox.Icons.SearchBox.png")]
public class RadSearchBox : RadDataBoundControl, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IScriptControl, IControlResolver, IPostBackDataHandler, ISkinnableControl, IControl, IFeatureGroup, IPostBackEventHandler, ICallbackEventHandler, IFlatBoundContainer, INamingContainer

Inheritance: objectControlWebControlBaseDataBoundControlDataBoundControlRadDataBoundControlRadSearchBox...

Implements: IAttributeAccessorICallbackEventHandlerIComponentIControlIControlBuilderAccessorIControlDesignerAccessorIControlResolverIDataBindingsAccessorIDisposableIExpressionsAccessorIFeatureGroupIFlatBoundContainerINamingContainerIParserAccessorIPostBackDataHandlerIPostBackEventHandlerIScriptControlISkinnableControlIUrlResolutionService...

Inherited Members DataBoundControl.OnCreatingModelDataSource(CreatingModelDataSourceEventArgs)DataBoundControl.GetData()DataBoundControl.GetDataSource()DataBoundControl.MarkAsDataBound()DataBoundControl.OnDataPropertyChanged()DataBoundControl.OnDataSourceViewChanged(object, EventArgs)DataBoundControl.OnLoad(EventArgs)DataBoundControl.PerformDataBinding(IEnumerable)DataBoundControl.PerformSelect()DataBoundControl.ValidateDataSource(object)DataBoundControl.DataMemberDataBoundControl.IsUsingModelBindersDataBoundControl.ItemTypeDataBoundControl.SelectMethodDataBoundControl.DataSourceIDDataBoundControl.DataSourceObjectDataBoundControl.CreatingModelDataSourceDataBoundControl.CallingDataMethodsBaseDataBoundControl.ConfirmInitState()BaseDataBoundControl.DataBind()BaseDataBoundControl.EnsureDataBound()BaseDataBoundControl.OnDataBound(EventArgs)BaseDataBoundControl.OnInit(EventArgs)BaseDataBoundControl.OnPreRender(EventArgs)BaseDataBoundControl.DataSourceBaseDataBoundControl.InitializedBaseDataBoundControl.IsBoundUsingDataSourceIDBaseDataBoundControl.IsDataBindingAutomaticBaseDataBoundControl.SupportsDisabledAttributeBaseDataBoundControl.RequiresDataBindingBaseDataBoundControl.DataBoundWebControl.ApplyStyle(Style)WebControl.CopyBaseAttributes(WebControl)WebControl.CreateControlStyle()WebControl.MergeStyle(Style)WebControl.Render(HtmlTextWriter)WebControl.RenderBeginTag(HtmlTextWriter)WebControl.RenderEndTag(HtmlTextWriter)WebControl.AccessKeyWebControl.AttributesWebControl.BackColorWebControl.BorderColorWebControl.BorderWidthWebControl.BorderStyleWebControl.ControlStyleWebControl.ControlStyleCreatedWebControl.CssClassWebControl.DisabledCssClassWebControl.StyleWebControl.EnabledWebControl.EnableThemingWebControl.FontWebControl.ForeColorWebControl.HasAttributesWebControl.IsEnabledWebControl.SkinIDWebControl.TabIndexWebControl.TagNameWebControl.ToolTipWebControl.WidthControl.ResolveAdapter()Control.HasEvents()Control.GetRouteUrl(object)Control.GetRouteUrl(string, object)Control.GetRouteUrl(RouteValueDictionary)Control.GetRouteUrl(string, RouteValueDictionary)Control.GetUniqueIDRelativeTo(Control)Control.ApplyStyleSheetSkin(Page)Control.OnDataBinding(EventArgs)Control.DataBind(bool)Control.DataBindChildren()Control.AddParsedSubObject(object)Control.EnsureID()Control.ClearChildState()Control.ClearChildControlState()Control.ClearChildViewState()Control.ClearEffectiveClientIDMode()Control.ClearCachedClientID()Control.LoadControlState(object)Control.MapPathSecure(string)Control.OpenFile(string)Control.BuildProfileTree(string, bool)Control.SaveControlState()Control.RenderChildren(HtmlTextWriter)Control.RenderControl(HtmlTextWriter)Control.RenderControl(HtmlTextWriter, ControlAdapter)Control.OnUnload(EventArgs)Control.RaiseBubbleEvent(object, EventArgs)Control.OnBubbleEvent(object, EventArgs)Control.AddedControl(Control, int)Control.CreateControlCollection()Control.ResolveUrl(string)Control.ResolveClientUrl(string)Control.FindControl(string)Control.FindControl(string, int)Control.GetDesignModeState()Control.HasControls()Control.IsLiteralContent()Control.EnsureChildControls()Control.RemovedControl(Control)Control.SetDesignModeState(IDictionary)Control.SetRenderMethodDelegate(RenderMethod)Control.ClientIDModeControl.ClientIDControl.ClientIDSeparatorControl.ContextControl.AdapterControl.DesignModeControl.EventsControl.IDControl.IsChildControlStateClearedControl.EnableViewStateControl.ViewStateModeControl.IsViewStateEnabledControl.NamingContainerControl.IdSeparatorControl.LoadViewStateByIDControl.PageControl.RenderingCompatibilityControl.TemplateControlControl.ParentControl.TemplateSourceDirectoryControl.AppRelativeTemplateSourceDirectoryControl.SiteControl.VisibleControl.HasChildViewStateControl.ControlsControl.ValidateRequestModeControl.ViewStateControl.ViewStateIgnoresCaseControl.ChildControlsCreatedControl.IsTrackingViewStateControl.DisposedControl.DataBindingControl.InitControl.LoadControl.PreRenderControl.Unloadobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

C#
public RadSearchBox()

Properties

Gets the RadSearchBox SearchBoxButtons collection.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public SearchBoxButtonCollection Buttons { get; }
C#
protected SearchBoxButtonCollection Children { get; }

Gets the settings for the animation played when the dropdown closes.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public AnimationSettings CollapseAnimation { get; }
Property Value:

An AnimationSettings that represents the collapse animation.

Use the CollapseAnimation property to customize the expand animation of RadSearchBox. You can specify the Type and Duration. To disable collapse animation effects you should set the Type to AnimationType.None.
To customize the expand animation you can use the ExpandAnimation property.

Example:
cs-api-definition
void Page_Load(object sender, EventArgs e)
{
RadSearchBox1.CollapseAnimation.Type = AnimationType.Linear;
RadSearchBox1.CollapseAnimation.Duration = 300;
}

The client-side id of the inner input element used for intergation with RadLabel

C#
public string ControlId { get; }

The CssClass property will now be used instead of the former Skin and will be modified in AddAttributesToRender()

C#
protected override string CssClassFormatString { get; }

Overrides: RadDataBoundControl.CssClassFormatString

Example:
C#
protected override string CssClassFormatString
{
       get
       {
           return "RadDock RadDock_{0} rdWTitle rdWFooter";
       }
}

Gets or sets the selected culture. Localization strings will be loaded based on this value.

C#
public CultureInfo Culture { get; set; }
Property Value:

The culture.

Gets or sets the DataContextKeyField. This property will define the data column used as a context field.

C#
public virtual string DataContextKeyField { get; set; }
Property Value:

The DataContextKeyField.

Gets or sets an array of data-field names that will be used to populate the DropDownItem's DataItem property.

C#
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
[TypeConverter(typeof(ListConverter))]
[PersistenceMode(PersistenceMode.Attribute)]
public virtual string[] DataKeyNames { get; set; }
Property Value:

An array that contains the names of the fields contained in the DropDownItem's DataItem property.

Note: Values set to this property are case-sensitive! The field names should be coma-separated.

Gets or sets the DataTextField.

C#
public virtual string DataTextField { get; set; }
Property Value:

The DataTextField.

Implements: IFlatBoundContainer.DataTextField

Gets or sets a value indicating how the DropDownItems text should be formatted.

C#
public virtual string DataTextFormatString { get; set; }

Gets or sets the DataValueField.

C#
public virtual string DataValueField { get; set; }
Property Value:

The DataValueField.

Implements: IFlatBoundContainer.DataValueField

Used to customize the appearance and position of the buttons displayed by RadListBox.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public DropDownSettings DropDownSettings { get; }

Gets or sets a message when the input of the RadSearchBox is empty.

C#
[ClientControlProperty]
[ClientPropertyName("_emptyMessage")]
[Bindable(false)]
public virtual string EmptyMessage { get; set; }
Property Value:

The message which will be shown when the input of the RadSearchBox is empty.

Gets or sets a value indicating whether WAI-ARIA support is enabled.

C#
[ClientControlProperty]
[ClientPropertyName("_enableAriaSupport")]
public bool EnableAriaSupport { get; set; }
Property Value:

true if WAI-ARIA support is enabled; otherwise, false. The default is false.

When enabled, the SearchBox control will render appropriate ARIA attributes to improve accessibility for screen readers such as JAWS. This includes:

  • ARIA roles for the input and dropdown list
  • ARIA states for expanded/collapsed dropdown
  • ARIA live regions for announcing search results
  • ARIA attributes for keyboard navigation support

Gets or sets a value indicating whether the AutoComplete functionality of the RadSearchBox is enabled.

C#
[Bindable(false)]
[ClientControlProperty]
[ClientPropertyName("_enableAutoComplete")]
public virtual bool EnableAutoComplete { get; set; }

Determines whether the Direction Detection is enabled or not.

C#
[Bindable(false)]
[ClientControlProperty]
[ClientPropertyName("_enableDirectionDetection")]
public bool EnableDirectionDetection { get; set; }

Determines whether the Screen Boundaries Detection is enabled or not.

C#
[Bindable(false)]
[ClientControlProperty]
[ClientPropertyName("_enableScreenBoundaryDetection")]
public bool EnableScreenBoundaryDetection { get; set; }

Gets the settings for the animation played when the dropdown opens.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public AnimationSettings ExpandAnimation { get; }
Property Value:

An AnimationSettings that represents the expand animation.

Use the ExpandAnimation property to customize the expand animation of RadSearchBox. You can specify the Type and Duration. To disable expand animation effects you should set the Type to AnimationType.None.
To customize the collapse animation you can use the CollapseAnimation property.

Example:
cs-api-definition
void Page_Load(object sender, EventArgs e)
{
RadSearchBox1.ExpandAnimation.Type = AnimationType.Linear;
RadSearchBox1.ExpandAnimation.Duration = 300;
}

Gets or sets a value indicating whether the RadSearchBox should apply “Contains” or “StartsWith” filter logic.

C#
[Bindable(false)]
[ClientControlProperty]
public SearchBoxFilter Filter { get; set; }

Gets or sets the height of the Web server control.

C#
public override Unit Height { get; }
Property Value:

A Unit that represents the height of the control. The default is Empty.

Exceptions: ArgumentException

The height was set to a negative value.

Overrides: RadDataBoundControl.Height

Gets or sets a value indicating whether the first matching result will be highlighted upon drop down opening.

C#
[Bindable(false)]
[ClientControlProperty]
[ClientPropertyName("_highlightFirstMatch")]
public virtual bool HighlightFirstMatch { get; set; }
C#
protected SearchContext InnerContext { get; }

Gets or sets a value that indicates whether the filter logic is case-sensitive or not.

C#
[Bindable(false)]
[ClientControlProperty]
[ClientPropertyName("isCaseSensitive")]
public bool IsCaseSensitive { get; set; }

Gets or sets the label of the control.

C#
public string Label { get; set; }
Property Value:

The label of the control.

Gets or sets the css class of the label.

C#
public string LabelCssClass { get; set; }
Property Value:

The label CSS class.

Gets or sets the width of the control's label

C#
public Unit LabelWidth { get; set; }

Gets the localization.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
[TypeConverter(typeof(ExpandableObjectConverter))]
public SearchBoxLocalization Localization { get; }
Property Value:

The localization.

Gets or sets a value indicating where RadSearchBox will look for its .resx localization files.

C#
public string LocalizationPath { get; set; }
Property Value:

The localization path.

Gets or sets how many results are shown in the dropdown.

C#
[Bindable(false)]
[ClientControlProperty]
[ClientPropertyName("maxResultCount")]
public virtual int MaxResultCount { get; set; }

Defines the minimum number of characters that must be typed before a search is made.

C#
[ClientControlProperty]
public virtual int MinFilterLength { get; set; }
Property Value:

The minimum number of characters that must be typed before a search is made.

Gets or sets a value indicating the client-side event handler that is called when a button from the Buttons Collection is clicked.

C#
[ClientControlEvent]
[ClientPropertyName("buttonCommand")]
public string OnClientButtonCommand { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is empty string.

If specified, the OnClientButtonCommand client-side event handler is called when a button from the Buttons Collection is clicked.

The event handler receives two parameters: the instance of the searchBox client-side object and event args.

This event cannot be cancelled.

Example:
C#
<p>&lt;script type="text/javascript"&gt;<br />
function onClientButtonCommandHandler(sender, args)<br />
{<br />
       alert(sender.get_id());<br />
}<br />
&lt;/script&gt;</p>
<p>&lt;telerik:RadSearchBox ID="RadSearchBox1"<br />
runat= "server"<br />
    <strong>OnClientButtonCommand="onClientButtonCommandHandler"</strong>&gt;<br />
....<br />
&lt;/telerik:RadSearchBox&gt;</p>

Gets or sets a value indicating the client-side event handler that is called before a search is triggered in RadSearchBox.

C#
[ClientControlEvent]
[ClientPropertyName("dataRequesting")]
public string OnClientDataRequesting { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is empty string.

If specified, the OnClientDataRequesting client-side event handler is called before a search is triggered in RadSearchBox .

The event handler receives two parameters: the instance of the searchBox client-side object and event args.

This event can be cancelled.

Example:
C#
<p>&lt;script type="text/javascript"&gt;<br />
function onClientDataRequestingHandler(sender, args)<br />
{<br />
       alert(args.get_text());<br />
}<br />
&lt;/script&gt;</p>
<p>&lt;telerik:RadSearchBox ID="RadSearchBox1"<br />
runat= "server"<br />
    <strong>OnClientDataRequesting="onClientDataRequestingHandler"</strong>&gt;<br />
....<br />
&lt;/telerik:RadSearchBox&gt;</p>

Gets or sets a value indicating the client-side event handler that is called after the RadSearchBox client-side object is initialized.

C#
[ClientControlEvent]
[ClientPropertyName("load")]
public string OnClientLoad { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is empty string.

If specified, the OnClienLoad client-side event handler is called after the searchBox is fully initialized on the client.

A single parameter - the searchBox client object - is passed to the handler.

This event cannot be cancelled.

Example:
C#
<p>&lt;script type="text/javascript"&gt;<br />
function onClientLoadHandler(sender)<br />
{<br />
       alert(sender.get_id());<br />
}<br />
&lt;/script&gt;</p>
<p>&lt;telerik:RadSearchBox ID="RadSearchBox1"<br />
runat= "server"<br />
    <strong>OnClientLoad="onClientLoadHandler"</strong>&gt;<br />
....<br />
&lt;/telerik:RadSearchBox&gt;</p>

Gets or sets a value indicating the client-side event handler that is called when a search is triggered in the SearchBox. This happens when the default seach button or an item from the dropdown is clicked, or Enter key is pressed.

C#
[ClientControlEvent]
[ClientPropertyName("search")]
public string OnClientSearch { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is empty string.

If specified, the OnClientSearch client-side event handler is called when a search is triggered in the SearchBox. This happens when the default seach button or an item from the dropdown is clicked, or Enter key is pressed.

The event handler receives two parameters: the instance of the searchBox client-side object and event args.

This event cannot be cancelled.

Example:
C#
<p>&lt;script type="text/javascript"&gt;<br />
function onClientSearchHandler(sender)<br />
{<br />
       alert(sender.get_id());<br />
}<br />
&lt;/script&gt;</p>
<p>&lt;telerik:RadSearchBox ID="RadSearchBox1"<br />
runat= "server"<br />
    <strong>OnClientSearch="onClientSearchHandler"</strong>&gt;<br />
....<br />
&lt;/telerik:RadSearchBox&gt;</p>

Gets the RadSearchBox SearchContext.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public SearchContext SearchContext { get; }
C#
protected DataSourceSelectArguments SelectArguments { get; }

Gets or sets a value indicating whether a loading icon should be shown while a request it pending.

C#
[Bindable(false)]
[ClientControlProperty]
[ClientPropertyName("showLoadingIcon")]
public bool ShowLoadingIcon { get; set; }

Gets or sets a value indicating whether the default search button is rendered.

C#
[Bindable(false)]
[ClientControlProperty]
[ClientPropertyName("_showSearchButton")]
public virtual bool ShowSearchButton { get; set; }
C#
protected override bool SupportsRenderingMode { get; }

Overrides: RadDataBoundControl.SupportsRenderingMode

C#
protected override HtmlTextWriterTag TagKey { get; }

Overrides: WebControl.TagKey

Gets or sets the RadSearchBox's input value.

C#
[Browsable(false)]
[Bindable(false)]
public virtual string Text { get; set; }
Property Value:

The value shown in the input of the RadSearchBox.

Gets the unique, hierarchically qualified identifier for the server control.

C#
[ClientControlProperty]
[ClientPropertyName("_uniqueId")]
public override string UniqueID { get; }
Property Value:

The fully qualified identifier for the server control.

Overrides: Control.UniqueID

Gets the settings for the web service used to provide search results.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public WebServiceSettings WebServiceSettings { get; }
Property Value:

An WebServiceSettings that represents the web service used to provide search results.

Use the WebServiceSettings property to configure the web service used to provide search results. You must specify both Path and Method to fully describe the service.

In order to use the integrated support, the web service should have the following signature:

   <pre><code class="lang-csharp">[ScriptService]

public class WebServiceName : WebService { [WebMethod] public SearchBoxItemData[] GetResult(SearchBoxContext context) {

} }

<System.Web.Script.Services.ScriptService()> _
Public Class WebService
Inherits System.Web.Services.WebService

   <WebMethod> _
   Public Function GetResult(context As SearchBoxContext) As SearchBoxItemData()

   End Function

End Class

Methods

C#
protected override void AddAttributesToRender(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter

Overrides: RadDataBoundControl.AddAttributesToRender(HtmlTextWriter)

C#
protected override void CreateChildControls()

Overrides: Control.CreateChildControls()

This method should return object that implements ISearchBoxRenderer or Inherits the SearchBoxRenderer class.

C#
protected override IRenderer CreateControlRenderer()
Returns:

IRenderer

Overrides: RadDataBoundControl.CreateControlRenderer()

C#
protected override DataSourceSelectArguments CreateDataSourceSelectArguments()
Returns:

DataSourceSelectArguments

Overrides: DataBoundControl.CreateDataSourceSelectArguments()

C#
protected override void DescribeComponent(IScriptDescriptor descriptor)
Parameters:descriptorIScriptDescriptor

Overrides: RadDataBoundControl.DescribeComponent(IScriptDescriptor)

C#
[SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
public override void Dispose()

Overrides: Control.Dispose()

C#
protected virtual void Dispose(bool disposing)
Parameters:disposingbool
C#
public override void Focus()

Overrides: Control.Focus()

C#
protected string GetPostbackEventReference()
Returns:

string

C#
protected void LoadDropDownItems(SearchBoxContext context)
Parameters:contextSearchBoxContext

Executed when post data is loaded from the request

C#
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
Parameters:postDataKeystringpostCollectionNameValueCollectionReturns:

bool

Overrides: RadDataBoundControl.LoadPostData(string, NameValueCollection)

C#
protected override void LoadViewState(object savedState)
Parameters:savedStateobject

Overrides: DataBoundControl.LoadViewState(object)

Raises the ButtonCommand event.

C#
protected void OnButtonCommand(SearchBoxButtonEventArgs e)
Parameters:eSearchBoxButtonEventArgs

The SearchBoxButtonEventArgs instance containing the event data.

Raises the DataSourceSelect event.

C#
protected bool OnDataSourceSelect(SearchBoxDataSourceSelectEventArgs e)
Parameters:eSearchBoxDataSourceSelectEventArgs

The SearchBoxDataSourceSelectEventArgs instance containing the event data.

Returns:

bool

C#
protected override void OnPagePreLoad(object sender, EventArgs e)
Parameters:senderobjecteEventArgs

Overrides: DataBoundControl.OnPagePreLoad(object, EventArgs)

Raises the Search event.

C#
protected void OnSearch(SearchBoxEventArgs e)
Parameters:eSearchBoxEventArgs

The SearchBoxEventArgs instance containing the event data.

C#
protected virtual void RaisePostBackEvent(string eventArgument)
Parameters:eventArgumentstring
C#
protected override void RenderContents(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter

Overrides: RadDataBoundControl.RenderContents(HtmlTextWriter)

C#
protected override object SaveViewState()
Returns:

object

Overrides: DataBoundControl.SaveViewState()

C#
protected override void TrackViewState()

Overrides: DataBoundControl.TrackViewState()

Events

Occurs when a button has been clicked.

C#
public event SearchBoxButtonEventHandler ButtonCommand

Occurs before a select command is sent to the datasource.

C#
public event SearchBoxDataSourceSelectEventHandler DataSourceSelect

Occurs when a search has been triggered.

C#
public event SearchBoxEventHandler Search