RadComboBox for ASP.NET

AllowCustomText cannot be disabled when loading items on demand Send comments on this topic.
TroubleShooting > AllowCustomText cannot be disabled when loading items on demand

Glossary Item Box

When you load the combobox items on demand (in the ItemsRequested event) the AllowCustomText property is enabled by default. You cannot disable it as this would break the load-on-demand mechanism.

The ItemsRequested event is fired when the user types in the Telerik RadComboBox input field or clicks the drop-arrow image. Disabling the AllowCustomText property would prevent the user from typing in the input field and this would break the load-on-demand mechanism. Therefore we decided that the best approach is to hard-code the value of the AllowCustomText property and set it to true when the combobox is in a callback mode. 

 

WORKAROUND

To work around the problem you could use the following approach:

Example:

ASPX Copy Code
<script>
       
//Hook on the OnClientDropDownOpening event and in its event handler call the RequestItems method -
       //to add the items
       function AddItems(combo)
       {
           combo.RequestItems();
       }
</script>
//Hook on the ItemsRequested event without enabling the EnableLoadOnDemand property
//Thus, the AllowCustomText property will not be enabled by the combobox
<rad:radcombobox
           
id="RadComboBox1"
           
runat="server"
           
OnItemsRequested="RadComboBox1_ItemsRequested"
           
OnClientDropDownOpening="AddItems"
           
AllowCustomText="false">
</rad:radcombobox>
C# Copy Code
protected void RadComboBox1_ItemsRequested(object o, Telerik.WebControls.RadComboBoxItemsRequestedEventArgs e)
   {
       RadComboBox1.Items.Add(
new RadComboBoxItem("item1", "1"));
       RadComboBox1.Items.Add(
new RadComboBoxItem("item2", "2"));
       RadComboBox1.Items.Add(
new RadComboBoxItem("item3", "3"));
   }