kumar
kumar

Reputation: 1127

Set the date to raddatepicker by using Javascript

I am getting a date value from server side and passing it to javascript method and then i am assigning the date to Telerik RadDatePicker control using Javascript.

I am getting date as

var Date1="16/01/2013 00:00:00";
function SetDate(Date1)
{
 var datepicker = $find("<%= RadDatePicker1.ClientID %>"); 
 datepicker.set_selectedDate(Date1); 
}

datepicker.value=Date1; to display the date.but i am Unable to display the date in raddatepicker

Upvotes: 2

Views: 9580

Answers (1)

Michael
Michael

Reputation: 498

This question was old, but here goes... It may just be that your date is not valid. Try just setting the variable to "new Date();" first. If that works, check your date. This seems to work fine for me:

<script type="text/javascript">
    var Date1 = new Date("1/16/2013 00:00:00");
    function SetDate(myDate) {
        var datepicker = $find("<%= RadDatePicker1.ClientID %>");
        datepicker.set_selectedDate(myDate);
    }
    // For the demo, make sure to set the date after the picker has fully loaded by MS AJAX,
    // but if calling SetDate from the server, it should be fine.
    Sys.Application.add_load(function () {
        SetDate(Date1);
    });
</script>

Upvotes: 1

Related Questions