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

RadDatePicker Client Events Not Working After an Ajax Update (Partial Postback)

1 Answer 123 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Oran
Top achievements
Rank 1
Oran asked on 26 Aug 2010, 02:18 PM
Hi,

I am new to telerik controls and I have inherited a website that heavily relies on Telerik controls.

I have created 2 raddatepickers. One of them has a client event OnDateSelected that updates the 2nd datepicker with a calculated date based on the first one. This works fine until another control on the same page/panel causes a partial postback (using the RadAjaxManager). After the partial postback my client event can no longer access the raddatepicker client object.

I have set the client event to be reattached after the partial postback. I don't know if that is necessary. ( I assumed it was based on this page http://www.telerik.com/help/aspnet/toolbar/toolbar_clienteventsunattached.html). I know that the event is reattached b/c I have stepped into the code using Firebug. However, when the set_selectedDate function runs nothing happens to the 2nd datepicker.

Here is the code that I used:

              <telerik:RadDatePicker ID="dateTetanusReceived" runat="server">
           <ClientEvents OnDateSelected="TetanusDateSelected"></ClientEvents>
            </telerik:RadDatePicker>
              <telerik:RadDatePicker ID="dateTetanus" runat="server">
            </telerik:RadDatePicker>
var _TetanusExpiryPicker = $find("<%= dateTetanus.ClientID %>");
 var _TetanusPicker = $find("<%= dateTetanusReceived.ClientID %>");
 
function TetanusDateSelected(sender, e) {
 
    SetSecondDatePicker(_TetanusExpiryPicker, 10, e);
}
 
function SetSecondDatePicker(datePicker, yearsToAdd, e) {
    var expiryDate = e.get_newDate();
    expiryDate.setFullYear(expiryDate.getFullYear() + yearsToAdd);
    datePicker.set_selectedDate(expiryDate);
}
 
//Event gets called after a partial postback ends
function OnResponseEndHandler(sender, arguments) {
 
    _TetanusPicker.add_dateSelected(TetanusDateSelected);
}

Any help would be appreciated.

Oran

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 31 Aug 2010, 01:33 PM
Hello Oran,

I tried to replicate the issue which you described, but to no avail.
Attached to this message, you will find the code which I used for testing.

Please, take a look at it and let me know if there are any differences at your end, which I may be leaving out.

Additionally, I would like to mention that it is not necessary to reattach the event handlers after partial postback.

All the best,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Ajax
Asked by
Oran
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or