I am trying to use the AutoCompleteBox control.
I only want to let the user select one instance of each token. My list of tokens contains "Test 1, "Test 2" and "Test 3".
I am using a function on the OnClientEntryAdding that checks whether the entry has already been added.
If I type in "Test" and select "Test 1", it's added to the list of tokens. If I type in "tes" and then select "Test 1" then the token is not added which is what I want. But if I then type in "tes" and select "Test 1" then the event is cancelled but the text in the control is "Test 1 ;tes". It seems that the text is still changed even if the entry has been cancelled. How can I prevent it from adding an invalid token?
If I save the entries, then it's ok because the collection of entries doesn't contain the invalid entry but I don't want to display that invalid entry.
Below is the setting of my control
Thanks
I only want to let the user select one instance of each token. My list of tokens contains "Test 1, "Test 2" and "Test 3".
I am using a function on the OnClientEntryAdding that checks whether the entry has already been added.
<script type="text/javascript"> function entryAdding(sender, eventArgs) { var txt = sender.get_text(); var entries = sender.get_entries(), count = entries.get_count(); for (var i = 0; i < count; i++) { if (entries.getEntry(i).get_value() == eventArgs.get_entry().get_value()) { eventArgs.set_cancel(true); } } }</script>If I type in "Test" and select "Test 1", it's added to the list of tokens. If I type in "tes" and then select "Test 1" then the token is not added which is what I want. But if I then type in "tes" and select "Test 1" then the event is cancelled but the text in the control is "Test 1 ;tes". It seems that the text is still changed even if the entry has been cancelled. How can I prevent it from adding an invalid token?
If I save the entries, then it's ok because the collection of entries doesn't contain the invalid entry but I don't want to display that invalid entry.
Below is the setting of my control
<telerik:RadAutoCompleteBox runat="server" ID="ACBVoie" DataTextField="Desc_No_Voie" DataValueField="No_Voie" InputType="Token" width="100%" OnClientEntryAdding="entryAdding" AllowCustomToken="false"> </telerik:RadAutoCompleteBox >Thanks
