Javascript无法在使用Ajax ASP.Net的response.redirect上运行 [英] Javascript not working on response.redirect using ajax ASP.Net

查看:45
本文介绍了Javascript无法在使用Ajax ASP.Net的response.redirect上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将ASP.Net页面重定向到下载页面,并且我正在使用ajax.重定向页面确实起作用,下载了文件,并显示了称为下载的页面.下载文件后,我需要调用javascript以删除等待屏幕.

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 to call javascript after the file is downloaded to remove the waiting screen.

我首先调用重定向,然后使用javascript取消阻止用户界面.阻止UI,我正在使用onclientclick ='block()';

I am first calling redirect then javascript to unblock the UI. to block the UI i'm doing that using onclientclick='block()';

  Response.Redirect("ExportFile.aspx, false);
 ScriptManager.RegisterClientScriptBlock((this), this.GetType(), "alertAction", "alert('');unblock();", true);

即使警报无法正常工作,所以也完全不会触发JS.我厌倦了将代码放在文件下载页面上,但这也不起作用.我什至尝试了body onpageunload,但也没有触发.

even the alert isn't working so the JS isn't being fired at all. I tired putting the code on the file download page but that doesn't work either. I even tried body onpageunload but that never fires either.

如何重定向到文件下载页面,然后调用JS解除对用户界面的阻止?

How can I redirect to a file download page then call JS to unblock the UI?

推荐答案

boruchsiper是正确的.另外,一旦您将它们重定向到另一个页面(如果我的假设是正确的,那么您将重定向到另一个页面).您可能希望在到达新页面后触发此行,因此您希望在Load()函数后面的该页面的代码中:

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);

您可能希望在该重定向URL中包含一个查询字符串,以告知该页面执行该操作.

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

这篇关于Javascript无法在使用Ajax ASP.Net的response.redirect上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆