Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 21st, 2005, 07:58 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default How Avoid Dialog Box Open/Save Files

Hello:
I’m sending a Crystal Reports’s report to Word, but a dialog box is opening where user is asking if wish open/save file.
I’d like avoid this dialog emerges and report be displayed directly in screen as user would press open button.
I’m attaching code I’m using:

string ExportPath = sRuta + "CrystalReport1" + ".doc";

crvReportes.ReportSource = cr;
CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions ();

cr.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.Disk File;

cr.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.WordForWi ndows;
DiskOpts.DiskFileName = ExportPath;

cr.ExportOptions.DestinationOptions = DiskOpts;

cr.Export();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/msword";
Response.WriteFile(ExportPath);
Response.Flush();
Response.Close();
System.IO.File.Delete(ExportPath);

Where crvReportes is my CrystalReportViewer y cr is my ReoprtDocument
I’ll thank your help.
A.L.

El Hombre que tiene Amigos ha de mostrarse Amigo
__________________
El Hombre que tiene Amigos ha de mostrarse Amigo
  #2 (permalink)  
Old February 22nd, 2005, 12:35 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

After setting the ContentType ... make use of Content-disposition parameter of Response.AddHeader. Just check the syntax .. i guess it would be something like this:

Response.AddHeader("Content-disposition", "attachment; filename=test.doc");

note instead of attachment we can also set inline or something. Just chk the documentation.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
  #3 (permalink)  
Old February 22nd, 2005, 01:19 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Vadivel:
I was trying placing this line after ContentType:
Response.AddHeader("Content-disposition", "attachment; filename=ExportPath");
or
Response.AddHeader("Content-disposition", "inline; filename=ExportPath");
But still dialog box appears.
Regards.
A.L.

El Hombre que tiene Amigos ha de mostrarse Amigo
  #4 (permalink)  
Old February 22nd, 2005, 02:22 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello:
Surely I need to be more explicit.
I'm trying to export a report from a CrystalReportViewer to a location within client machine, I write it therein and then I want display it imto web page, I want avoid dialgog box asking if user want open or save file. I want that it be displayed into a web form without such a dialog, if instead Word document I export it to .pdf format it is displayed directly without such a dialog.
How can I achieve it in Word?
A.L.


El Hombre que tiene Amigos ha de mostrarse Amigo
  #5 (permalink)  
Old February 23rd, 2005, 07:36 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code I’m using is:

Response.ClearContent();
                                Response.ClearHeaders();
                                Response.Clear();
                                Response.ContentType = "application/msword";
                                Response.Charset = "";

                                Response.AddHeader("Content-disposition", "inline; filename=ExportPath");
                                Response.AddHeader("Content-Length", sFileLength);

                                Response.WriteFile(ExportPath);
                                Response.Flush();
                                Response.Close();
                                System.IO.File.Delete(ExportPath);

If file to display was not MS-Word neither MS-Excel, as a PDF file, then dialog box is not showed.

How can I in MS files to such dialog not be showed?

A.L.



El Hombre que tiene Amigos ha de mostrarse Amigo


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I forcefully opne the save dialog box janakiraman ASP.NET 3.5 Basics 1 April 16th, 2008 07:35 AM
Save As Dialog Box prasanta2expert Access VBA 0 June 23rd, 2007 07:35 AM
Save Dialog Box Camer Servlets 9 February 23rd, 2006 09:10 AM
Save dialog box mcinar Classic ASP Basics 6 January 15th, 2005 12:49 AM
Can Open/save dialog box be eliminated? janice_2k4 VBScript 2 June 14th, 2004 03:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.