设置日期使用Javascript功能来raddatepicker [英] Set the date to raddatepicker by using Javascript

查看:427
本文介绍了设置日期使用Javascript功能来raddatepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到来自服务器端的日期值并将它传递给JavaScript方法,然后我使用的JavaScript分配日期Telerik的RadDatePicker控制。

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.

我收到日期

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

datepicker.value =日期1;显示date.but我无法显示raddatepicker日期

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

推荐答案

这个问题是老了,但在这里不用...这可能只是你的日期无效。尝试只设置变量为新的Date();第一。如果这样的作品,请检查您的日期。这似乎为我工作的罚款:

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>

这篇关于设置日期使用Javascript功能来raddatepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆