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

7 posts, 0 answers
  1. Majid Darab
    Majid Darab avatar
    110 posts
    Member since:
    Sep 2012

    Posted 13 Jan 2010 Link to this post

    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...
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Jan 2010 Link to this post

    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.
  3. Majid Darab
    Majid Darab avatar
    110 posts
    Member since:
    Sep 2012

    Posted 14 Jan 2010 Link to this post

    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....
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Jan 2010 Link to this post

    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.
  5. Majid Darab
    Majid Darab avatar
    110 posts
    Member since:
    Sep 2012

    Posted 14 Jan 2010 Link to this post

    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

  6. Majid Darab
    Majid Darab avatar
    110 posts
    Member since:
    Sep 2012

    Posted 15 Jan 2010 Link to this post

    any idea ?????
  7. Jeremy
    Jeremy avatar
    1 posts
    Member since:
    Nov 2010

    Posted 19 Nov 2010 Link to this post

    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? 
Back to Top