Avatar of Sirdots
Sirdots
 asked on

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

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

Open in new window

.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
Sirdots

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
vbwizardry

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Sirdots

ASKER
Thanks for your fast response/assistance
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy