使用c#在asp.net中提示保存对话框 [英] Prompting a Save dialog in asp.net using c#

查看:85
本文介绍了使用c#在asp.net中提示保存对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i在asp.net创建了水晶报道,



ni添加了一个导出为PDF按钮。



但是在这里我想提示用户将文件保存到其特定目的地。



plz帮帮我,如何提示保存对话框到导出文件。



我的代码:

Hi guys,

i have created crystal reports in asp.net,

n i have added one "Export to PDF" button.

But here i want to prompt the user to save the file to its specific destination.

plz help me, how to prompt save dialog to the exporting file.

my code:

ReportDocument cryRpt = new ReportDocument();

                cryRpt = (ReportDocument)Session["Report"];

                ExportOptions CrExportOptions;

                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();

                PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();

                CrDiskFileDestinationOptions.DiskFileName = "E:\\csharp.net-informations.pdf";
//Here i want to prompt the user to save file to its specific destination.

                CrExportOptions = cryRpt.ExportOptions;

                {

                    CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;

                    CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                    CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;

                    CrExportOptions.FormatOptions = CrFormatTypeOptions;

                }

                cryRpt.Export();





请建议我。



谢谢



Please suggest me.

Thanks

推荐答案

此代码实际上在服务器文件系统中创建了一个PDF。您需要做的是读取文件,将其写入页面的响应流,设置正确的响应类型并关闭流。浏览器将根据用户设置采取适当的操作,即它可以在浏览器中打开文件进行查看,或者使用另存为对话框提示用户。
This code actually creates a PDF in the server file system. What you need to do is read the file, write it to the Response Stream of the page, set the correct Response Type and close the stream. The browser will take appropriate action based on user settings, i.e. it may open the file within the browser for viewing or prompt the user with the Save As dialog.


这篇关于使用c#在asp.net中提示保存对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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