RadAjax firing after RadToolTipUpdate

11 posts, 0 answers
  1. Sam
    Sam avatar
    66 posts
    Member since:
    Mar 2011

    Posted 03 Jan 2012 Link to this post

    Hopefully someone can help me out here.  I have a radtooltip that uses ajax and that works fine on the page.  I also have a radajaxmanager object that works fine as well.  The radajaxmanager has both OnRequestStart and OnResponseEnd events.  When calling any ajaxified control, the process works correctly, however, when I cancel an ajax request in the OnRequestStart event (by calling eventArgs.set_enableAjax(false) and eventArgs.set_cancel(true);), the OnResponseEnd event fires after I hover over the tooltip.  The arguments are the same as the prior cancelled event so I'm led to believe the prior ajax call really didn't cancel and the OnResponseEnd is called after my radtooltip's ajax call.  Also, if I click another button and the process is allowed to go through (without cancelling), the tooltip works fine on subsequent calls.  Any help would be appreciated.

    Another thing, the tooltip never fires the OnRequestStart or OnResponseEnd AjaxManager events.  It is only after an ajax request is cancelled will this happen.  
  2. Sam
    Sam avatar
    66 posts
    Member since:
    Mar 2011

    Posted 03 Jan 2012 Link to this post

    Just an update, I ended up using the ToolTipOnClientBeforeShow and ToolTipOnClientHide events for the tooltip to set a local variable (tooltipShowing) and checking the variable first in the OnResponseEnd event of the RadAjaxManager. 

    var tooltipShowing = false;
    function ToolTipOnClientBeforeShow() { tooltipShowing = true; }
    function ToolTipOnClientHide() { tooltipShowing = false; }

    function AjaxRequestEnd(sender, eventArgs) {
    if (tooltipShowing) { eventArgs.set_cancel(true);return false; }
    ...
    }

    It seems there should be some way of preventing this action.  Maybe the order in which I'm doing something is causing this weird behavior.  The problem I've experienced with workarounds like this is that perhaps this will trip some other issue later on or maybe I'm covering up a previous error that I've overlooked.   

  3. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 06 Jan 2012 Link to this post

    Hello Sam,

    The provided information is not enough for us to fully understand your scenario. Could you please provide a little bit more details?
    How do you show the tooltip, what are the AJAX settings and why do you disable the AJAX when the tooltip is showing?

    I am looking forward to your reply.

    Regards,
    Mira
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  4. Sam
    Sam avatar
    66 posts
    Member since:
    Mar 2011

    Posted 06 Jan 2012 Link to this post

    Sorry for the lack of information.  The Tooltip is updated through Ajax using the onAjaxUpdate event.  Everything works fine until I click an ajaxified button that is canceled before the ajax request is completed.  For instance, I have a delete button that first confirms whether the delete should take place.  If not, I cancel the Ajax request in the AjaxManager's ClientEvents-OnRequestStart by using the eventArgs.set_cancel(true) method.  On any subsequent tooltips (through Ajax), the tooltip shows briefly and then the AjaxManager's ClientEvents-OnRequestStart event executes but contains the same sender and eventArgs values as the prior delete button so I can't trap it to see if it is really the Tooltip making the call.  Also, I read that the tooltip is actually making a manual call when using ajax so maybe that is the issue.  Either way, I had to manually set a variable (my post just before your reply) in order to check whether the ajax request is being made by the tooltip or not.  Hopefully this clears it up a bit.
  5. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 09 Jan 2012 Link to this post

    Hello,

    You can access the UniqueID of the AJAX initiator on RequestStart using the get_eventTarget() method.
    The sender of the event is always the corresponding RadAjaxManager.
    Please use this approach and let me know whether it helps.

    If the issue persists, please send sample code demonstrating the problem.

    Kind regards,
    Mira
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  6. Sam
    Sam avatar
    66 posts
    Member since:
    Mar 2011

    Posted 09 Jan 2012 Link to this post

    Mira, see attached sample and do the following steps:
    1.  hover over tooltip.  Tooltip is shown fine (no ajax client events are fired)
    2.  click the save link.  both ajax client events are fired.
    3.  hover over tooltip.  (same as step 1)
    4.  click the delete link.  ajaxrequeststart is fired and the event is cancelled.
    5.  hover over tooltip.  notice how ajaxrequestend event is fired with same arguments as previously cancelled delete link.

    Question is why is this?  My workaround was to try and trap when this is the case since there is no way of knowing the ajaxendevent is being fired now because of the previously cancelled event.  Also, if you click back on the save link, both ajax events are fired and the tooltip works fine.  The ajaxmanager seems to be getting crossed up in there somehow.

    .ASPX

    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script language="javascript" type="text/javascript">
            function AjaxRequestStart(send, eventArgs) {
                alert("AjaxRequestStart " + eventArgs.get_eventTarget() + " " + eventArgs.get_eventArgument());
                if (eventArgs.get_eventArgument() == 0) {
                    eventArgs.set_cancel(true);
                    return false;
                }
            }
            function AjaxRequestEnd(sender, eventArgs) {
                alert("AjaxRequestEnd " + eventArgs.get_eventTarget() + " " + eventArgs.get_eventArgument());
                $find("<%=rnEventNotification.ClientID %>").show();
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="AjaxRequestStart" ClientEvents-OnResponseEnd="AjaxRequestEnd">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rtbEvent">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rtbEvent" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="rnEventNotification" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default" />
    <telerik:RadNotification ID="rnEventNotification" runat="server" EnableShadow="true" Text="" Title="" />
    <telerik:RadToolBar ID="rtbEvent" runat="server" Width="100%" Height="30" EnableEmbeddedSkins="false" Skin="Category">
        <Items>
            <telerik:RadToolBarButton Value="Delete" CommandName="Delete" Text="Delete"></telerik:RadToolBarButton>
            <telerik:RadToolBarButton Value="Save" CommandName="Save" Text="Save"></telerik:RadToolBarButton>
        </Items>
    </telerik:RadToolBar>
    <telerik:RadToolTipManager ID="rttmEventPreview" OffsetY="-1" Width="350" Height="350" runat="server" EnableShadow="true" 
        OnAjaxUpdate="OnAjaxUpdateToolTip" HideEvent="LeaveTargetAndToolTip" RelativeTo="Element" Position="MiddleRight">
    </telerik:RadToolTipManager>
    </form>

    .ASPX.VB

    Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack And Not RadAjaxManager1.IsAjaxRequest Then
            Dim hyp As New HyperLink
            hyp.NavigateUrl = "#
            hyp.Text = "link1"
            form1.Controls.Add(hyp)
            rttmEventPreview.TargetControls.Add(hyp.ClientID, "1", True)
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(hyp, rttmEventPreview)
            Dim lit As New Literal
            lit.Text = "<br/>"
            form1.Controls.Add(lit)
            hyp = New HyperLink
            hyp.NavigateUrl = "#
            hyp.Text = "link2"
            form1.Controls.Add(hyp)
            rttmEventPreview.TargetControls.Add(hyp.ClientID, "2", True)
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(hyp, rttmEventPreview)
            lit = New Literal
            lit.Text = "<br/>"
            form1.Controls.Add(lit)
        End If
    End Sub
    Protected Sub OnAjaxUpdateToolTip(sender As Object, args As ToolTipUpdateEventArgs)
        Me.UpdateToolTip(args.Value, args.UpdatePanel)
    End Sub
    Private Sub UpdateToolTip(elementID As String, panel As UpdatePanel)
        Dim lbl As New Label
        lbl.Text = "the time is " & Date.Now
        panel.ContentTemplateContainer.Controls.Add(lbl)
    End Sub
    Private Sub rtbEvent_ButtonClick(sender As Object, e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbEvent.ButtonClick
        Dim btn As RadToolBarButton = TryCast(e.Item, RadToolBarButton)
        If Not btn Is Nothing Then
            If btn.CommandName = "Delete" Then
                rnEventNotification.Title = "Activity Deleted"
                rnEventNotification.Text = "Activity deleted successfully"
            ElseIf btn.CommandName = "Save" Then
                rnEventNotification.Title = "Activity Saved"
                rnEventNotification.Text = "Activity saved successfully"
            Else
                rnEventNotification.Title = ""
                rnEventNotification.Text = ""
            End If
        End If
    End Sub
  7. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 12 Jan 2012 Link to this post

    Hello,

    The described issue is expected due to the behavior of the PageRequestManager.
    You can examine the attached project for additional information.

    I hope this helps.

    All the best,
    Mira
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  8. Sam
    Sam avatar
    66 posts
    Member since:
    Mar 2011

    Posted 12 Jan 2012 Link to this post

    It is doing the exact same thing with your code.  What I would expect is that when an Ajax request is actually canceled (using args.set_cancel(true);) that the request does not trigger the AjaxRequestEnd event when the tooltip is activated.  Seeing that this is expected behavior.  I would need a way of checking in the AjaxRequestEnd that the tooltip is now active and is causing the AjaxRequestEnd event to trigger.  Basically the notification you see should not appear when they hover over a tool tip.  Why is it that the page continues to try and process the AjaxRequestEnd event after every tool tip when I cancel an original ajax request? 

    Also, what is the prm.abortPostBack() actually doing? It appears that it is not doing anything. 
  9. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 12 Jan 2012 Link to this post

    Hello,

    The behavior demonstrated in my project is the expected one due to the way the PageRequestManager, on which the RadAjaxManager depends, works.
    You can see that the EndRequest event is fired by the manager, even though the postback is canceled with the abortPostBack method.

    Please let me know if any further questions arise.

    Kind regards,
    Mira
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  10. Sam
    Sam avatar
    66 posts
    Member since:
    Mar 2011

    Posted 12 Jan 2012 Link to this post

    Ok, I'm going to try and be a little more specific.  I have a form that uses ajax for all the postbacks.  Whenever a button is clicked on the toolbar, I display a notification message after the request is complete (in the ClientEvents-OnResponseEnd event on the RadAjaxManager).  I also use ajax to update the contents of a radtooltip.  If the user clicks the delete button on the toolbar, I give a confirm message asking if the user wants to continue.  If so, the ajax request is sent and on the response end, I display a notification.  If the user cancels, I cancel the ajax request.  However on any subsequent tool tips, the ClientEvents-OnResponseEnd is fired.  It never fires for the tool tip until the delete button's request is cancelled.  So my question is why does it fire the event after supposedly canceling an ajax request.  Also, like I stated earlier, even when the ClientEvents-OnResponseEnd event fires, the arguments contain that of the delete button.  Everything could very well be working as expected and the initial workaround I implemented works fine, but there is still something wrong with the fact that the AjaxRequestManager will continue to fire OnResponseEnd events after an ajax request is canceled. And what is causing the OnResponseEnd?  Is it the tool tip?  Obviously I guess, but why wouldn't the arguments be for the tooltip and not the previously canceled ajax button?
  11. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 18 Jan 2012 Link to this post

    Hi Sam,

    After further research on the problem and deeper investigation by our developers we conclude that the presented behaviour is a bug in the RadAjax. We already logged this bug in out tracking system and a fix will be available in the upcoming beta release.
    For now you could avoid this behaviour by terminating the request in the PageRequestManager InitializeRequest event, like this:
    Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(Initialize);
     
     function Initialize(sender, args) {
          
         var prm = Sys.WebForms.PageRequestManager.getInstance();
         alert("PRM_request_start");
         if (prm.get_isInAsyncPostBack() & args.get_postBackElement().id == 'rtbEvent') {
     
             args.set_cancel(true);
            prm.abortPostBack();
       }
     }

    Thank you for reporting this to us and for your cooperation.

    All the best,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top