我有一个< ASP:按钮/> 生成PDF格式的报告。我想使用jQuery BlockUI显示一条消息,上面写着:生成报告。
I have an <asp:button /> that generates a PDF report. I want to use jQuery BlockUI to display a message that says: Generating Report..
使用: Response.BinaryWrite 我然后将文件发送给用户,以便它显示为在浏览器中的文件下载
Using: Response.BinaryWrite I am then sending the file to the user so it appears as a file download in the browser.
我不能让 $ unblockUI(); 火。一旦文件下载开始或已完成或取消,我希望它dissappear。目前,它从来不会..它好像页面没有被重新加载,我已经打了服务器,但它与同一页回来。
I cannot get $.unblockUI(); to fire. As soon as the file download begins or has completed or is cancelled I want it to dissappear. Currently it never does.. It's as though the page hasn't been re-loaded, I've hit the server but it comes back with the same page.
东西我曾尝试:
- 在JS的变量设置为true,因此在的document.ready()它会调用一个函数,如果设置为true。这不起作用,因为即使我改变变量code它不会更改发送到客户端的HTML。
- 这样的事情: Sys.WebForms.PageRequestManager.getInstance()add_pageLoaded(函数(){$ .unblockUI;}); //与微软的方式登记(文档)$ .ajaxStop($ unblockUI); //双保险,使用jQuery的方式注册不会被调用。
- Setting a variable in JS to true so on document.ready() it will call a function if set to true. This doesn't work because even though I change the variable in code it doesn't change the HTML that is sent to the client.
- This sort of thing: Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function() { $.unblockUI; }); //register with Microsoft way $(document).ajaxStop($.unblockUI); //double the insurance and register with jquery way never gets called..
这能与一个UpdatePanel实现?
Can this be achieved with an updatepanel?
有什么想法?
此外,在情况下,它可以帮助
Also in case it helps:
Response.AddHeader("Content-Disposition", "attachment;filename=""" & ShortFilename & """") Response.AddHeader("Content-Length", byteArray.Length) Response.BinaryWrite(byteArray) Response.Flush() Response.End()我明白为什么这不工作排序,页面不刷新,无论如何也只是被发送到浏览器的响应流,但肯定有一个事件,我可以锁存到?
I can see why this doesn't work sort of, the page is not refreshing in anyway there's just a response stream being sent to the browser, but surely there's an event I can latch on to?
推荐答案的解决方案是第一阻塞UI为正常。然后,让一个AJAX请求到报表生成器,当PDF是很短的时间产生它在本地存储,或者当用户注销或他们的登录超时有它在被清除出临时文件夹。有报告生成器返回成功消息和网址。
The solution is to first block the UI as normal. Then make an AJAX request to your report generator, when the PDF is generated store it locally for a short time, or have it in a temporary folder that is cleared out when the user logs out or their login times out. Have the report generator return a success message and a URL.
在客户端Ajax请求处理成功的消息,删除BlockUI,然后使用调用的网址:
Have the client ajax request handle the success message, remove BlockUI, then call the URL using:
window.location="yourURL/temp/report.pdf浏览器将开始下载文件和你做!
The browser will start to download the file and you are done!
stackoverflow/a/7660817/181197
更多推荐
通过响应流发送给浏览器的文件后,不阻止(jQuery的BlockUI)
发布评论