Disable a RAD combo box using javascript

7 posts, 0 answers
  1. saravanan k
    saravanan k avatar
    88 posts
    Member since:
    Mar 2010

    Posted 05 Jun 2010 Link to this post

    hi,

    I have a asp:Button. OnCLientClick of the button, I call a javascript method-> Test()

    function Test()
    {
    document.getElementById('Id of the combo box').disabled=true;
    }

    I am unable to do so. Please advice on how to proceed.

    Thanks,
    Saravanan
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Jun 2010 Link to this post

    Hello Saravanan,

    Use the folowing code in order to disable the ComboBox.

    Client Code:
    var combo = $find("<%= ComboBox1.ClientID %>");   
    combo.disable();  

    You can also refer following link to online documentation which explains client side methods of combo.
    Client-Side Basics

    Regards,
    Princy.
  3. David Simmonds
    David Simmonds avatar
    56 posts
    Member since:
    Mar 2010

    Posted 22 Oct 2010 Link to this post

    enable() and disable() are invalid methods for a RadComboBox.

    This does not work:

     

     

    var cb = document.getElementById("<%= RadComboBoxBIN.ClientID %>");

     

    cb.enable();


    I have to use document.getElementById because $find returns null.

    Why can I not use enable()/disable() now? What do I use instead?

    This also does not enable or disable the combobox. It does not cause an error like enable()/disable() does but it has no effect.

    document.getElementById(

     

    "<%= RadComboBoxBIN.ClientID %>").disabled = false;

     


    document.getElementById(

     

    "<%= RadComboBoxBIN.ClientID %>").disabled = true;

    Does anyone have any ideas?

     

  4. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 22 Oct 2010 Link to this post

    Hello David,

    If you are trying to disable it when the page loads. I assume you are trying to disable/enable when the page loads, if you get null from $find. You would have to do this to disable the RadComboBox:

    Sys.Application.add_load(DisableRadComboBox);
      
    function DisableRadComboBox()
    {
       var combo = $find("<%=RadComboBox1.ClientID%>");
       combo.disable();
    }

    You would create another one that would do the reverse.

    I hope that helps.
  5. David Simmonds
    David Simmonds avatar
    56 posts
    Member since:
    Mar 2010

    Posted 25 Oct 2010 Link to this post

    I tried using the documented enable() and disable() methods but when I run the code and I try to use enable() or disable() I get an error indicating that those methods are not valid. Why is this? The methods are documented. http://www.telerik.com/help/aspnet-ajax/combo_clientsideradcombobox.html
  6. David Simmonds
    David Simmonds avatar
    56 posts
    Member since:
    Mar 2010

    Posted 25 Oct 2010 Link to this post

    Turns out you have to use $find and not document.getelementbyid to get the full api of the object.
  7. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 26 Oct 2010 Link to this post

    Hi David Simmonds,

    The document.getElementById returns a DOM object, and $find returns the AJAX control client-side object.

    I will recommend you use $find to get the RadComboBox client-side object, and after that use the enable() and disable() functions.
    Please find more details about RadComboBox client-side methods and properties here.

    Greetings,
    Kalina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top