This is a migrated thread and some comments may be shown as answers.

Date Selected Client Side Event

1 Answer 125 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Gary asked on 29 Sep 2008, 04:27 PM

I want to handle the client side events that fires when the date is changed on that date picker control of the radScheduler.

In the OnInit event of the page I hook up the event using


dp = this.RadScheduler1.FindControl("SelectedDatePicker") as RadDatePicker;
dp.ClientEvents.OnDateSelected =

on my aspx page in the script i have the function

function SchedulerSelectedDatePicker_OnDateSelected(sender, eventArgs)
    var date = eventArgs.get_renderDay().get_date();
    int offset  = date.getTimezoneOffset();

My first problem is that for some reason the event is not firing. What could be the problem here.

Once I have sorted that and got it firing I want to pass the value of offset that I calculate in the function back to the server with the partial postback. What's my best  way of doing this? Stick the value in a hidden field or is there another way?



1 Answer, 1 is accepted

Sort by
T. Tsonev
Telerik team
answered on 30 Sep 2008, 03:52 PM
Hi Gary,

You seem to be very close. We just need to care of some details. First, the OnPreRenderComplete event is the proper place to attach the event to the date picker:

protected override void OnPreRenderComplete(EventArgs e) 
    RadDatePicker dp = RadScheduler1.FindControl("SelectedDatePicker"as RadDatePicker; 
    dp.ClientEvents.OnDateSelected = "SchedulerSelectedDatePicker_OnDateSelected"

The client-side code also needed some little touch-ups:

<script type="text/javascript"
    function SchedulerSelectedDatePicker_OnDateSelected(sender, eventArgs) 
        // You will need this code after the Q3 release, 
        // as we will be replacing the RadDatePicker with a plain RadCalendar 
        // var date = eventArgs.get_renderDay().get_date(); 
        var date = eventArgs.get_newValue(); // The date is still a string here 
        var offset = new Date(date).getTimezoneOffset(); 
        // ... 

As for passing this to the server... I guess a hidden field will work out. You can also handle the DateSelecting event, cancel it, and use RadAjaxManager's AjaxRequest to post back to the server and perform your custom logic, as well as to change the RadScheduler's date.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Asked by
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question