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

Capture page events while using RadAjaxPanel

7 Answers 182 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Alejandro
Top achievements
Rank 1
Alejandro asked on 01 Jul 2010, 08:32 PM
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?

7 Answers, 1 is accepted

Sort by
0
SamJ
Top achievements
Rank 1
answered on 02 Jul 2010, 06:30 AM
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
0
Alejandro
Top achievements
Rank 1
answered on 02 Jul 2010, 01:34 PM
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....
0
Maria Ilieva
Telerik team
answered on 06 Jul 2010, 12:48 PM
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
0
Alejandro
Top achievements
Rank 1
answered on 06 Jul 2010, 01:57 PM
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?

0
Accepted
Maria Ilieva
Telerik team
answered on 06 Jul 2010, 02:23 PM
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
0
Alejandro
Top achievements
Rank 1
answered on 06 Jul 2010, 02:55 PM
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 

0
Maria Ilieva
Telerik team
answered on 07 Jul 2010, 02:52 PM
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
Tags
Ajax
Asked by
Alejandro
Top achievements
Rank 1
Answers by
SamJ
Top achievements
Rank 1
Alejandro
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or