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

Allow to select only one text item or a single token item in RadAutoCompleteBox


How to make the AutoComplete allow only one text entry or a single token.


The AutoCompleteBox is designed to allow users to select many items. Nevertheless, the following approach will achieve the single selection functionality.

In the OnClientLoad event, subscribe to the keypress event of the input element of the AutoCompleteBox. In the event handler of the keypress event, you can check if the entries collection has any entries, and if it does, prevent the keypress event.

    function OnClientLoad(sender, args) {
        $telerik.$(sender.get_inputElement()).on('keypress', function (e) {
            if (sender.get_entries().get_count() > 0) {
                // optionally, notify user that a single selection is allowed
<telerik:RadAutoCompleteBox runat="server" Width="250px" EmptyMessage="Choose a single text item..."
    InputType="text" TextSettings-SelectionMode="Single" ID="RadAutoCompleteBox1" OnClientLoad="OnClientLoad">
<br />
<telerik:RadAutoCompleteBox runat="server" Width="250px" AllowCustomEntry="false" EmptyMessage="Choose a single token item..."
    InputType="Token" ID="RadAutoCompleteBox2" OnClientLoad="OnClientLoad">
protected void Page_Init(object sender, EventArgs e)
    var dataSource = new string[] { "One", "Two", "Three" };
    RadAutoCompleteBox1.DataSource = dataSource;
    RadAutoCompleteBox2.DataSource = dataSource;
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
    Dim dataSource = New String() {"One", "Two", "Three"}
    RadAutoCompleteBox1.DataSource = dataSource
    RadAutoCompleteBox2.DataSource = dataSource
End Sub

See also

In this article