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

how can i show a message at the top of combobox like choose an item ...

6 Answers 242 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Majid Darab
Top achievements
Rank 1
Majid Darab asked on 14 Jan 2010, 04:17 AM
hi my dear experts :
i want to show a message in the textbox of RadComboBox When It's Load Like plz Choose an item.
i mean i do not want to have an item with this message as text and i want show the message at radcombobox load.
for this porpose radcombobox shouldn't put the first item as a selected item...
empty message property works when we make an empty item in radcombo box but i don't want an empty item in my list items and do n't let my user to choose an empty item...

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 14 Jan 2010, 07:12 AM
Hello Majid,

The Empty message property will work with the AllowCustomText property of the combobox, and so you dont have to add a empty list item to the ItemCollection of the combobox. Here's an example:
aspx:
<telerik:RadComboBox ID="RadComboBox1" AllowCustomText="true" EmptyMessage="-please select any-" runat="server"
   <Items> 
       <telerik:RadComboBoxItem Text="Item1" /> 
       <telerik:RadComboBoxItem Text="Item2" /> 
   </Items> 
</telerik:RadComboBox> 

-Princy.
0
Majid Darab
Top achievements
Rank 1
answered on 14 Jan 2010, 08:58 AM
hello  my dear Princy
i have a sql datasource that is connected to rad combobox ... and my user should choose items from it and should n't type a custom text by him/herself
nonetheless has custom text a selected value or text , so i can check it by validator and show a message to my users
=========================================================================================================
i saw validation of radcombobox help ....
but in there an item added to radcombobox with this text -> select a city beside databound items.... so user can choose select a city from that list ...
but i don't want this item in my list and i want to show a message to  user such as select a city at top as choosen text....
0
Princy
Top achievements
Rank 1
answered on 14 Jan 2010, 10:06 AM
Hello Majid,

A suggestion would be to show the EmptyMessage by setting the AllowCustomText property of the combobox and then prevent the user from entering text, from client side as shown below:
aspx:
 
<telerik:Radcombobox ID="RadComboBox1" runat="server" AllowCustomText="True" EmptyMessage="-please select one-"
    <Items> 
        <telerik:RadComboBoxItem runat="server" Text="Item1"></telerik:RadComboBoxItem> 
        <telerik:RadComboBoxItem runat="server" Text="Item2"></telerik:RadComboBoxItem> 
    </Items> 
</telerik:Radcombobox> 

JavaScript:
 
<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) 
   { 
       e.preventDefault(); 
   } 
</script> 

Hope this helps...
Princy.
0
Majid Darab
Top achievements
Rank 1
answered on 14 Jan 2010, 02:27 PM
i really appreciate it
i test your java code and that was fantastic...

but stil some problems :

1-i forgot to tell you that i enabled markfirstmatch property for autocomplete purpose ... now what can i do about that?????

2-emptymessage have not any value in textbox so how can i check it with CampareValidatore and tell to user you should select some one if don't after click on a button


thanks a lot

0
Majid Darab
Top achievements
Rank 1
answered on 15 Jan 2010, 07:09 PM
any idea ?????
0
Jeremy
Top achievements
Rank 1
answered on 19 Nov 2010, 08:54 PM
Trapping the key strokes is interesting, however it prevents the user from using keystrokes to jump to or highlight items in the list.  Is there a better solution that permits using the emptyMessage and allows for users to use keys to direct the item in the list to be selected? 
Tags
ComboBox
Asked by
Majid Darab
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Majid Darab
Top achievements
Rank 1
Jeremy
Top achievements
Rank 1
Share this question
or