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

[Solved] MVC DateTimePicker, jquery/javascript. Getting the object. Undefined

1 Answer 96 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James
Top achievements
Rank 1
James asked on 01 Dec 2011, 03:14 AM
Anybody know why I cannot get a handle on this object? I've tried everything. Always undefined. I need to disable and enable the datetimepicker.

I'm using Telerik v2011.2.712.340

In the View: 
        <div align="left" class="divColMedium">
          <div class="editor-label">
            @Html.LabelFor(model => model.EndDate)
          </div>
          <div class="editor-field">
            @(Html.Telerik().DatePicker().Name("EndDate").Value(Model.EndDate))
            @Html.ValidationMessageFor(model => model.EndDate)
          </div>
        </div>


<script type="text/javascript">
   function getDateTimePicker() {
     var dateTimePicker = $('#EndDate').data('tDateTimePicker'); // WHY ALWAYS UNDEFINED???
     
     //var dateTimePicker = $('#EndDate').tDateTimePicker.defaults
     //dateTimePicker.enabled=false;


     return dateTimePicker;
  }
</script>

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 05 Dec 2011, 05:31 PM
Hello James,

 
You need to get the client object of the DatePicker, not the client object of the DateTimePicker. Check this help topic for more information.

Greetings,
Georgi Krustev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Date/Time Pickers
Asked by
James
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or