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

Diable DatePicker when loaded

2 Answers 47 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 07 Oct 2008, 03:09 PM
Using the folowing code in the OnLoad function for the body of my page I get a null for my datepicker object:

var datepicker = $find("<%= DatePicker.ClientID %>");
datepicker.get_dateInput().disable();

I am trying to have a datepicker object enabled or disabled depending on the value of another field in my page when the screen is loaded.  Is there a better way to do this?  I would prefer to have it on the client side if at all possible.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 07 Oct 2008, 03:14 PM
Hi Jim,

<body onload="..."> is too early to reference the date picker client object, because it has not been created yet.

Please use

<script type="text/javascript">

Sys.Application.add_load(disablePicker);

function disablePicker()
{
     var datepicker = $find("<%= DatePicker.ClientID %>");
     datepicker.get_dateInput().disable();

}

</script>


Sincerely yours,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jim
Top achievements
Rank 1
answered on 10 Oct 2008, 12:57 PM
Thank you, I'm working through an issue I'm having with the Rad Grid at the moment and will try this solution once I'm done with that.
Tags
Calendar
Asked by
Jim
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Jim
Top achievements
Rank 1
Share this question
or