To add a new item to the Autocomplete control, use the AllowAddNew and AddNewText APIs. The AllowAddNew is used to allow or restrict the Autocomplete control from adding a new item to the list. It accepts Boolean value. By default, the value of the AllowAddNew property is false. You can set it to true to add a new text in the Autocomplete control. The AddNewText API is used to add a new item to the list items. It accepts String value. By default, the value of the AddNewText API is Add New.
To add a new text in the Autocomplete control, enable AllowAddNew API, which allows you add a new text to the Autocomplete text box. After setting the AllowAddNew API to true, add new text using the AddNewText API.
This new text will be added to suggestions for only one time. If you remove this newly added item, it will not be present in the suggestions. Hence, you need to add this new item to the datasource if you want this to be visible again in the suggestion list.
Note: AddNewText can be used in the Visual mode only.
In the attached sample, the AllowAddNew and AddNewText APIs have been included. When you type the text that does not present in the list, it shows the text given in the AddNewText API.
After selecting the entered text in the Autocomplete popup, it is added in the Autocomplete control as shown in the following screenshot.
If you remove this item and search again this new word, it will be shown in the suggestion list since it has already been added in the datasource.
Thus, you can add new text in the Autocomplete control dynamically.
This page will automatically be redirected to the sign-in page in 10 seconds.