PDA

View Full Version : [CLOSED] Redirect in ajaxevent



Jurke
Oct 07, 2008, 9:55 AM
Hi
I have an ajaxevent that I want to do a redirect in.


Response.Redirect("Test.aspx");

That results in an error, is there another way to do this?

or do I have to use javascript


window.location = 'Text.aspx';


Best regards
Mikael Jürke

geoffrey.mcgill
Oct 07, 2008, 10:29 AM
Hi Mikael,

The following forum post should help, see http://forums.ext.net/showthread.php?threadid=2590-4-1.aspx

Summary: yes, you would need to use the window.location JavaScript.

Jurke
Oct 07, 2008, 10:37 AM
Okay
thanks.

Best regards
Mikael Jürke

Jurke
Oct 07, 2008, 10:58 AM
I have a follow up quesiton. The .NET redirect does not allow the user to hit the back button, but the javascript does. Is there a workaround for this aswell?

Best regards
Mikael Jürke

geoffrey.mcgill
Oct 10, 2008, 10:42 AM
Hi Mikael,

We added functionality to automatically handle a Response.Redirect during an AjaxEvent. You no longer need to manually add the "window.location" script. Just call Response.Redirect() as you typically would do and the Toolkit will function as expected.


I ran a few tests using Response.Redirect and then clickig the "back button". The back button appears to function exactly the same during a typical AutoPostBack or AjaxEvent. 

Jurke
Oct 10, 2008, 11:01 AM
Hi
That great, but if you try the Response.Redirect("page2.aspx"); from the PageLoad in page1.aspx. You will not be able to push the backbutton in the browser to get to page1.aspx again. The behaviour is ekvivalent to the javascript window.location.replace('page2.aspx');

Best regards
Mikael Jürke

geoffrey.mcgill
Oct 10, 2008, 11:14 AM
hmmm...

If you are doing a Response.Redirect in the Page_Load event, you will never be able to view that Page. It will always redirect everytime it's loaded. It's impossible for the back button to work in your scenario.

Using your sample example of "Page1" and "Page2", now add two buttons to the Page. One <asp:Button> and one <ext:Button>. Wire up the <asp:Button> to do a PostBack and the <ext:Button> to do an AjaxEvent.

Then do a Response.Redirect from the click event handlers of both buttons. You will see that the back button functions exactly the same.

Hope this helps.

Jurke
Oct 10, 2008, 11:23 AM
Hi yes you are right!
Thank.

Best regards
Mikael Jürke

jchau
Nov 18, 2008, 7:36 PM
In my our application, we catch the Application_Error event in global.asax. We log the error and then redirect to an user friendly error page. If an error occurs during an AjaxEvent, the redirect fails with

Can not redirect after HTTP headers have been sent.

Is there another way to get around this?

geoffrey.mcgill
Nov 18, 2008, 7:52 PM
Hi jchau,

I think we might need to see a simplified Project demonstrating the full scenario. I'll run a couple tests in an attempt to reproduce.

geoffrey.mcgill
Nov 18, 2008, 7:54 PM
Actually... could you start a new thread with your topic. Then post a cross link here to the new thread. 

jchau
Nov 18, 2008, 8:30 PM
geoffrey.mcgill (11/18/2008)Actually... could you start a new thread with your topic. Then post a cross link here to the new thread.





Done. New thread at :

http://forums.ext.net/showthread.php?threadid=4077-16-1.aspx