Set the date to raddatepicker by using Javascript

孤者浪人 提交于 2019-12-13 16:05:57

问题


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


回答1:


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>


来源:https://stackoverflow.com/questions/14357272/set-the-date-to-raddatepicker-by-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!