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

2 posts, 0 answers
  1. Oran
    Oran avatar
    6 posts
    Member since:
    Aug 2010

    Posted 26 Aug 2010 Link to this post

    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
  2. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 31 Aug 2010 Link to this post

    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
Back to Top