开发者

Setting RadDatePicker Date Without Firing ValueChanged

Using the client API, I'd like to be able to do this:

picker.set_selectedDate(new Date());

Without the valueChanged event handler firing, is there another way in the API to do this? Again this 开发者_运维技巧is all client-side JavaScript.

Thanks.


You can remove the event handler from the datepicker and then set the date, like this:

 var datePicker = $find("<%= RadDatePicker1.ClientID %>");            
 datePicker.remove_dateSelected(DateSelected);
 datePicker.set_selectedDate(new Date());

this will prevent the event from being fired, if you need it you can add it again after. The DateSelected is the name of the event that you have set on the control, see below for a small example

<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="SM" runat="server"></asp:ScriptManager>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
    function pageLoad() {
        var datePicker = $find("<%= RadDatePicker1.ClientID %>");            
        datePicker.remove_dateSelected(DateSelected);
        datePicker.set_selectedDate(new Date());
    }

    function DateSelected(sender, e) {
        alert(sender);
    }
</script>
</telerik:RadCodeBlock>
<div>
     <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
        <ClientEvents OnDateSelected="DateSelected" />                       
     </telerik:RadDatePicker>
</div>
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜