Diable DatePicker when loaded

3 posts, 1 answers
  1. Jim
    Jim avatar
    21 posts
    Member since:
    Oct 2007

    Posted 07 Oct 2008 Link to this post

    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. Answer
    Dimo
    Admin
    Dimo avatar
    8478 posts

    Posted 07 Oct 2008 Link to this post

    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.
  3. Jim
    Jim avatar
    21 posts
    Member since:
    Oct 2007

    Posted 10 Oct 2008 Link to this post

    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.
Back to Top