troubleshooting Question

Creating a pdf file using asp.net C# 2003 and to get a prompt window / Crystal Report

Avatar of Sirdots
Sirdots asked on
.NET ProgrammingASP.NET
2 Comments1 Solution2967 ViewsLast Modified:
I have this click button event in an asp.net page.
Note I am using asp.net 2003 1.1 framework. I want to be able
to generate a pdf file. It is working very well and once I click
on the button the document is opened in pdf format.

I want to be able to get a prompt that will ask me if I want to open
it or save as pdf. how can I acheive that please.

Something like this below in form of a small window

"Do you want to open or save this file
open  save  cancel"
private void Button2_Click(object sender, System.EventArgs e)
		{
			// Get the report document
			ReportDocument repDoc = getReportDocument();
			// Stop buffering the response
			Response.Buffer = false;
			// Clear the response content and headers
			Response.ClearContent();
			Response.ClearHeaders();
			try
			{
				// Export the Report to Response stream in PDF format and file name Customers
				MemoryStream oStream; // using System.IO
				oStream = (MemoryStream)
				repDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
				Response.Clear();
				Response.Buffer= true;
				Response.ContentType = "application/pdf"; 
				Response.BinaryWrite(oStream.ToArray());
				Response.End();	
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				ex = null;
			}
 
		}
ASKER CERTIFIED SOLUTION
vbwizardry

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros