Capture page events while using RadAjaxPanel

8 posts, 1 answers
  1. Alejandro
    Alejandro avatar
    5 posts
    Member since:
    Jul 2010

    Posted 01 Jul 2010 Link to this post

    On each content page I placed code in the Load event when Postback is true and False to capture that the user is still logged in. When the user interacts with the controls inside the RadAjax panel those lines of code in the Load event don't trigger. I also tried the Prerender event but it doesn't seem to trigger that event either.
    Problem: on which page event or panel event could I place my code that fires any time a user interacts with controls inside the RadAjax panel?
  2. SamJ
    SamJ avatar
    101 posts
    Member since:
    Jul 2008

    Posted 02 Jul 2010 Link to this post

    Hello,

    Ajaxifying a page does not affect its lifecycle. So with or without ajax the same events are fired and in the same sequence. The difference with ajax is that only small part of the page html is rendered back on the client. Therefore you should be still able to execute your logic in the Page_Load event handler. You can for instance try checking there if RadAjaxPanel1.IsAjaxRequest which will be true in case ajax request is invoked.

    I hope this helps.

    SamJ
  3. Alejandro
    Alejandro avatar
    5 posts
    Member since:
    Jul 2010

    Posted 02 Jul 2010 Link to this post

    I used a different approach to test the page event cycle, I placed a breakpoint in the Load_event inside the IsPostback= true statement and the app does not break....
  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 06 Jul 2010 Link to this post

    Hello Alejandro,

    You could try the following:

    protected void Page_PreRender(object sender, EventArgs e)
       {
           if (RadAjaxPanel1.IsAjaxRequest )
           {
             //Your code here       
           }
       }


    Regards,
    Maria Ilieva
    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
  5. Alejandro
    Alejandro avatar
    5 posts
    Member since:
    Jul 2010

    Posted 06 Jul 2010 Link to this post

    Maria, inside the RadAjaxPanel I have a dropdown list control, a button, some radio buttons, and textboxes. I tried your suggestion like this...

     

    Protected Sub Page_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.PreRender  
            If RadAjaxPanel.IsAjaxRequest Then 
                Response.Write("<script language='Javascript' type='text/javascript'>" & vbCrLf)  
                Response.Write("confirm('PostBack from PreRender event content page!!!.')" & vbCrLf)  
                Response.Write("</script>" & vbCrLf)  
            End If 
     
        End Sub 

    Neither when I make a new selection in the dropdownlist nor I click the button the event does not fire up....

    Do you think that I might be missing some properties settings on the Panel?

  6. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 06 Jul 2010 Link to this post

    Hi Alejandro,

    If you need to execute custom java script on Ajax update you should use the ResponseScripts property of the RadAjaxPanel or RadAjaxManager. Please refer to the following help topic for more information on this matter.

    Best wishes,
    Maria Ilieva
    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
  7. Alejandro
    Alejandro avatar
    5 posts
    Member since:
    Jul 2010

    Posted 06 Jul 2010 Link to this post

    The previous code was just a test, I guess it was the wrong test to performed. here is the actual code that I want to run everytime there is a request from the AjaxPanel. I want to make a call to a Java file that has a function with a counter that warms the user when it is about to be timed out...

     Protected Sub Page_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.PreRender  
            If RadAjaxPanel.IsAjaxRequest Then 
                Page.ClientScript.RegisterClientScriptInclude("alert", ResolveUrl("~\TimeoutMsg.js"))  
            End If 
     
        End Sub 

  8. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Jul 2010 Link to this post

    Hi Alejandro,

    Have you tried using the ResponseScripts property of the RadAjaxPanel or RadAjaxManager or the RegisterStartupScript static method of the ScriptManager class?

    All the best,
    Maria Ilieva
    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