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

[Solved] Disable dropdown using JS has different disabled color then disabling from server side

1 Answer 162 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rizwan
Top achievements
Rank 1
Rizwan asked on 16 Apr 2009, 11:23 AM
Hi
   I have a problem with disabled dropdown color. If I disable the dropdown from server side using Office2007 Skin then color goes gray which is good but if I disable the control using javascript then color stay white. I cannot change the skin as my entire application is configured to use that color scheme so I have not tested it on other skins but overall the color should go gray either we disable it using Server Side code or JS code.

The other problem is I am unable to find the Dropdown in JS using
document.getElementById  or $find or $get
one of them returns object and others null, the object one gives error that this is not its property.

Now I have attached the OnClientLoad event and either stores the object in global js variable or doing initial settings there.
I have tried different options posted on telerik forum to find dropdown but all invain.

I would like to upload the mini project with problems but could not find any upload option here. Please paste this code and test it at your end.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    
</head>
<body>
    <form id="form1" runat="server">
            <asp:ScriptManager runat="server" ID="smTest"></asp:ScriptManager>        
 
    <div>
        <p>Disabled color from Server side</p><telerik:RadComboBox ID="RadComboBox1" runat="server" >
        <Items>
            <telerik:RadComboBoxItem Text="This is disabled from Server end" />
            <telerik:RadComboBoxItem Text="Another text 1" />
        </Items>
        </telerik:RadComboBox>
        
        <p>Disabled from Client Side</p><telerik:RadComboBox ID="RadComboBox2" runat="server" OnClientLoad="ClientLoad">
        <Items>
            <telerik:RadComboBoxItem Text="Disable from Client Side" />
            <telerik:RadComboBoxItem Text="Another text" />
        </Items>
        </telerik:RadComboBox>
        <input type="button" onclick="return disableClientControl()" value="why Cant I get the dropdown" />
    </div>
     <script language="javascript" type="text/javascript">
         var ddl1;
         function ClientLoad(sender, args) {
             ddl1 = sender;
             ddl1.set_enabled(false);
         }
         function disableClientControl() {
             var ddl = document.getElementById("RadComboBox2")
             alert("next line will give JS error")
             ddl.set_enabled(false);
         }

    </script>
    </form>
   
</body>
</html>
-------------
SERVER SIDE CODE
------------

 protected void Page_Load(object sender, EventArgs e)
    {
        RadComboBox1.Enabled = false;
    }




1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 20 Apr 2009, 12:55 PM
Hi Rizwan,

Please refer to the attached website to find a live version of the answers to your problems.

1. disabling the combo on the client should be done through comboObject.disable();
2. getting the object to it works through the $find function. getElementById == $get - they get DOM elements. $find gets the client object.

Regards,
Alex
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
Rizwan
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or