Icemanind Icemanind - 1 year ago 177 Question

Adding empty string to RadComboBox

I have a webpage that has a Telerik RadComboBox on the page. One of the properties of this ComboBox is EmptyMessage, which fills the combobox with a message when an item is not selected. I am binding my combobox to a datasource at runtime and for some reason, it wipes this EmptyMessage away. Is there a way to keep my data items in tact and have the empty message there too? And default it to the empty message?

Answer Source

Seems like the accepted answer on Telerik says that you use client side script to prevent the text editing.

Telerik forum page

<telerik:Radcombobox ID="RadComboBox1" runat="server" AllowCustomText="True" EmptyMessage="-please select one-">    
    <telerik:RadComboBoxItem runat="server" Text="Item1"></telerik:RadComboBoxItem>     
    <telerik:RadComboBoxItem runat="server" Text="Item2"></telerik:RadComboBoxItem>     

<script type="text/javascript"> 
function pageLoad() 
   var combo = $find("<%= RadComboBox1.ClientID %>"); 
   var input = combo.get_inputDomElement(); 
   input.onkeydown = onKeyDownHandler; 
function onKeyDownHandler(e) 
  if (!e) 
  e = window.event;        
  e.returnValue = false; 
  if (e.preventDefault) 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download