Ajax模态弹出文件下载问题 [英] Ajax modal popup file download problem

查看:147
本文介绍了Ajax模态弹出文件下载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个Web应用程序,用户可以在网格视图中查看他的记录,单击参考ID时将弹出一个模式弹出窗口,其中显示单击的参考ID的全部详细信息.模态弹出窗口中存在一个导出为pdf"按钮,该按钮应将文档返回给用户.

我的问题是按钮的onclick会生成报告,但无法向用户显示文件保存/打开对话框.(相同的代码在单个页面上可以正常工作,但在AJAX模态弹出窗口中不能正常工作)

我的代码是:

Hi,

I have an webapplication in which the use can view his records in the grid view and on click on reference id will popup an modal popup which displays the full details of Reference id clicked. there is one export to pdf button exists within the modal pop up which should return the document to the user.

My problem is onclick of the button will generate the report but fails to display file save/open dialog to user.(the same code works fine with single page but not with AJAX modal popup)

my code is:

Context.Response.Clear();
        Context.Response.ContentType = "application/pdf";
        Context.Response.AddHeader("Content-Disposition", "attachment;filename=Test.pdf");
        Context.Response.Write("Hi");
        Context.Response.Flush();
 Context.Response.End();




如果有任何想法在ajax模态弹出窗口中下载文件的人,请帮助我.

谢谢,

Vasanth




please help me if any body having idea to download a file within ajax modal popup.

Thanks,

Vasanth

推荐答案

您必须为此创建一个http处理程序并从Java脚本调用此处理程序
You have to create a http handler for this and call this handler from java script


Response.Clear()
           Response.Buffer = True
           Response.ContentType = "application/pdf"
           Response.AddHeader("content-disposition", "attachment; filename=Test ")


这篇关于Ajax模态弹出文件下载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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