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

Cant get disable() to work

7 Answers 93 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mike Eaton
Top achievements
Rank 1
Mike Eaton asked on 05 Jan 2009, 11:27 AM
Hi,

I am trying to use the disable() javascript function to disable my dropdown but get the error message that the object does not support the method; I am using the combobox version "RadControls for ASPNET AJAX Q2 2008".

I am using the following code to try to disable the drop down: (the location combo box id is stored in a hidden text box locationTypeDDID)

locationTypeDD = document.getElementById(locationTypeDDID.value);
locationTypeDD.disabled();

I have also tried using code similar to:

var combo = $find("<%= RadComboBox1.ClientID %>");   

but the ("<%="s cause errors in my application due to the web page being dynamically built. I have also tried
var combo = $find(locationTypeDDID.value);   

but this returns a null object, where as document.getElementById(locationTypeDDID.value) does return the combo box object.

Thanks in advance for your help!

7 Answers, 1 is accepted

Sort by
0
Mike Eaton
Top achievements
Rank 1
answered on 05 Jan 2009, 11:28 AM
sorry just noticed a typo - im using locationTypeDD.disable(); not locationTypeDD.disabled();
0
Mike Eaton
Top achievements
Rank 1
answered on 12 Jan 2009, 02:02 PM
Any news on this please?
0
Accepted
Veselin Vasilev
Telerik team
answered on 12 Jan 2009, 02:09 PM
Hello Mike Eaton,

Please try this:

locationTypeDD = document.getElementById("locationTypeDDID"); 
 
var combo = $find(locationTypeDD.value); 
 
if (combo) combo.disable(); 

I hope this helps.

Kind regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike Eaton
Top achievements
Rank 1
answered on 12 Jan 2009, 03:41 PM
Thanks for your reply but unfortunatly that still does not work, the "combo object" is null so the disable code is not being called. Here is my code:


function

disableLocationTypeDD()

 

{

 

 

    var locationTypeDDID = document.getElementById("hiddenLocationDDID");

 

 

 

 

    if(locationTypeDDID != null)

 

    {

        var

combo = $find(locationTypeDDID.value);

 

 

 

        if (combo) combo.disable(); 
    }
}

where html is: 
 

 

<

html xmlns="http://www.w3.org/1999/xhtml" >

 

<

head runat="server">

 

</

head>

 

<

body onload="disableLocationTypeDD()">

 

 

<form  runat="server">

    <telerik:RadComboBox ID="locationTypeDD" runat="server"  EnableEmbeddedSkins="False">

 

    <

CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

    </

telerik:RadComboBox>

 

    <

asp:HiddenField ID="hiddenLocationDDID" runat="server" />

 

 

</form></body></html>

 

and in the code behind page I set the Client ID of locationTypeDD into hiddenLocationTypeRestrictDDID

0
Accepted
Veselin Vasilev
Telerik team
answered on 12 Jan 2009, 03:53 PM
Hi Mike Eaton,

I believe we are getting closer.
The problem is that in the body load method the javascript objects are still not initialized and that is why the combo object is null.
You need to call your function in the pageLoad() (fired after the Sys.load event) event where all the scripts are loaded and the objects are created and initialized.

I hope this helps.

Sincerely yours,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike Eaton
Top achievements
Rank 1
answered on 30 Jan 2009, 09:43 AM
Thank you very much for your help, it now works perfectly! I wasnt aware of the pageLoad() method before!
0
Paul
Telerik team
answered on 30 Jan 2009, 11:39 AM
Hello Mike,

pageLoad is a shortcut for the Sys.Application.load event. For details on the matter please refer to the following ASP.NET article.

Greetings,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Mike Eaton
Top achievements
Rank 1
Answers by
Mike Eaton
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Paul
Telerik team
Share this question
or