Enabled = false does not disable the dropdown

4 posts, 0 answers
  1. Olga
    Olga avatar
    20 posts
    Member since:
    Dec 2010

    Posted 16 Feb 2011 Link to this post

    Hi,

    I have an application that has just been upgraded to the latest ASP.NET AJAX controls.  I noticed that the following code:

    radComboUseStat.Items.Clear();
    radComboUseStat.Enabled = false;

    does not really disable the dropdown.  It looks disabled, but if you click on it, it still opens and, because it is empty, if you click again, it produces an error.

    It is definitely not disabled because I tried commenting out the first line, and I not only see my items in the dropdown (when I click on it), I can even select one!

    Thanks,
    Olga
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 17 Feb 2011 Link to this post

    Hello Olga,

    I tried to reproduce the issue that you encounter with the RadcomboBox (the latest version 2010 Q3), however, the combobox that I use renders disabled when I use the following code on the server-side:
    RadComboBox1.Items.Clear();
    RadComboBox1.Enabled = false;

     Even when I do not clear the items they get disabled and I can not select any. Which version of the controls do you use? Can you also send us a sample page which demostrates the issue, so we can explore it thoroughly?

    Kind regards,
    Kate
    the Telerik team
  3. Olga
    Olga avatar
    20 posts
    Member since:
    Dec 2010

    Posted 25 Feb 2011 Link to this post

    Hi Kate,

    I can't send you a page because it's a part of a huge application and won't do you any good.  But I can explain what's going on. 

    Here is a custom control (UseStatRadComboBox) that contains the combobox I am trying to enable/disable.

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="UseStat.ascx.cs" Inherits="SimpleSelectors_UseStat" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
      
    <table  style="width:180">
        <tr align="right">
            <td  style="width: 80px">
                <asp:Label ID="Label1" runat="server" Text="Use Stat:" CssClass="label_text"></asp:Label></td>
            <td style="height: 28px; width: 80px;" >
                <telerik:radcombobox id="UseStatRadComboBox" Width="80px" runat="server" LoadingMessage="" 
                OnClientDropDownOpened="dropDownOpened"></telerik:radcombobox>
                <script type="text/javascript">
                    Telerik.Web.UI.RadComboBoxItem.prototype.scrollOnTop = function () { };
                </script>
            </td>
        </tr>
    </table>

    From another object that contains this custom control (UseStat) I do this:

    RadComboBox radComboUseStat = (RadComboBox)this.UseStat.FindControl("UseStatRadComboBox");
    radComboUseStat.Items.Clear();
    radComboUseStat.Enabled = false;

    Now, if it's done not in PostBack, it works.  But we do it in PostBack, and it makes the combobox look disabled, but it's not.

    Thanks,
    Olga
  4. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 28 Feb 2011 Link to this post

    Hello Olga,

    I created a user control with the code that you provided and then used it in simple page. Then I disabled the user control from code behind and it seems to be working perfectly. Here is running sample page. My assumption is that you can not disable the ComboBox due to some JavaScript error or function that you use most probably in the user-defined control (UseStat). 

    Greetings,
    Kate
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top