我创建了一个telerik RadDatePicker,我可以通过创建var date = new Date() and using set_selectedDate(date)
方法在文本框中设置日期,如下所示:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
</telerik:RadDatePicker>
<input id="Button1" type="button" value="Set Date" onclick="SetDate();" />
<script type="text/javascript">
function SetDate() {
var date = new Date();
var datepicker = $find("<%= RadDatePicker1.ClientID %>");
datepicker.set_selectedDate(date);
}
</script>
我需要将日期作为字符串而不是对象传递,例如var date = "2016/11/11";
,然后将日期字符串传递给datepicker.set_selectedDate(date);
答案 0 :(得分:1)
试试这个;
function SetDate() {
var datepicker = $find("<%= RadDatePicker1.ClientID %>");
datepicker.set_selectedDate(new Date('2016/11/11'));
}