Skip to content Skip to sidebar Skip to footer

Javascript Not Working On Response.redirect Using Ajax Asp.net

I am redirecting the ASP.Net page to download page and i'm using ajax. The redirect page does work, the file is downloaded and the page that called the download is showing. I need

Solution 1:

Once response.redirect happens, no other code can execute. I would suggest to write your redirect code in javascript and put it into your RegisterClientScriptBlock. Just make sure the unblock is before the window.location.

ScriptManager.RegisterClientScriptBlock((this), this.GetType(), "alertAction", "unblock(); window.location.assign('yourPage.aspx');", true);

Solution 2:

boruchsiper is correct. Also, once you've redirected them, you're on a different page (if my assumption is correct that you're redirecting to a different page). You would want to fire off this line after arriving at the new page, so you'd want it in that page's code behind in the Load() function:

ScriptManager.RegisterClientScriptBlock((this), this.GetType(), "alertAction", "alert('');unblock();", true);

You may want to include a query string in that redirect URL to tell that page to take that action.

Post a Comment for "Javascript Not Working On Response.redirect Using Ajax Asp.net"