Change style when DropDownList.Enabled = false

4 posts, 0 answers
  1. bernhard schneider
    bernhard schneider avatar
    7 posts
    Member since:
    Jul 2012

    Posted 27 Mar 2013 Link to this post

    Hello,

    On my page I have some DropDownLists (created in codebehind) that works great .

    Skin: Default

    When there is no DropDownListItem in the DropDownList, I set myDdl.Enabled = false;

    I want change the style for the disabled DropDownList:
    color:  lightgrey
    border: lightgrey
    image on the right side: lightgrey

    How can I achive this?

    thanks
    Bernie

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Mar 2013 Link to this post

    Hi,

    Please check the sample code I tried at my end.

    C#:
    if (dropDownlist1.Items.Count==0)
    {
        dropDownlist1.Enabled = false;
        dropDownlist1.CssClass = "disabledStyle";
    }
    else
    {
        dropDownlist1.Enabled = true;
        dropDownlist1.CssClass = "enabledStyle";
    }

    CSS:
    <style type="text/css">
        .disabledStyle
        {
            border: 1px solid gray;
            color: Gray;
        }
        .enabledStyle
        {
            border: 1px solid Blue;
        }
    </style>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. bernhard schneider
    bernhard schneider avatar
    7 posts
    Member since:
    Jul 2012

    Posted 28 Mar 2013 Link to this post

    Hello,

    thanks, but that colors only an extra outer frame of the frame with the rounded corners (Image 1).

    What  I want is to grey the text and the frame with the rounded corners  (Image 2 --> first empty DropDownList).
    Here I set:
      DropDownList1.DefaultMessage = "<div style='color:#dddddd'>-------------------------</div>";
     
     
    Any ideas?


    Bernie
  5. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 02 Apr 2013 Link to this post

    Hello Bernhard,

    I would recommend you to download our latest internal build from today, which would apply the rddlDisabled class to the RadDropDownList, when it is disabled. In addition, you could use the following css style, in order to achieve the desired functionality:

    html .RadDropDownList_Default .rddlDisabled {
               border-color: #cccccc;
           }

    Please note, that the down-arrow could not be styled, since we are currently working on providing the appropriate css sprite image, addressing different styles and colors.

    Regards,
    Nencho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top