This is a migrated thread and some comments may be shown as answers.

selecting upto four tokens

1 Answer 14 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Lovella Bacaud
Top achievements
Rank 1
Lovella Bacaud asked on 05 Aug 2013, 07:56 AM
Hi
I am using an autocompletebox in my form to enter tokens. After selecting four token I want to disable further token selection. But the user should be able to delete one and add another.

Thanks
Lovella

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 05 Aug 2013, 08:07 AM
Hi Lovella,

Please have a look into the following code I tried which works fine at my end.

ASPX:
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" Label="Enter Name : "
    OnClientDropDownOpening="OnClientDropDownOpening" Width="400px" InputType="Token"
    DataSourceID="SqlDataSource1" DataTextField="ContactName">
</telerik:RadAutoCompleteBox>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="select ContactName from [Customers]"></asp:SqlDataSource>

JavaScript:
<script type="text/javascript">
    function OnClientDropDownOpening(sender, args) {
        if (sender.get_entries().get_count() >= 4) {
            args.set_cancel(true);
        }
    }
</script>

Thanks,
Shinu.
Tags
AutoCompleteBox
Asked by
Lovella Bacaud
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or