| | |
Opening a .pdf file at the clientside without the open/save dialog box
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Jul 2006
Posts: 10
Reputation:
Solved Threads: 0
Hi guys
Need some help with an problem thats bugging me..
I have to open a .pdf file at the client side when the user clicks a button..
Opening is not a problem.. I am able to do it using the following code
which is executed when the user clicks on the button
MyFileStream = New FileStream("E:\MyWork\Test\DownloadFiles\Reports\Rpt.pdf", FileMode.Open)
FileSize = MyFileStream.Length
Dim Buffer(CType(FileSize, Integer)) As Byte
MyFileStream.Read(Buffer, 0, CType(MyFileStream.Length, Integer))
MyFileStream.Close()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename=MyReport.PDF")
Response.BinaryWrite(Buffer)
The problem is that the user first sees a 'Open/ Save / Cancel' dialog box. Only when the user clicks on 'Open' does the .pdf file get opened.
My client wants it to be opened directly when the button is clicked.
Am at a loss and any help will be appreciated...
Thanks in advance
Need some help with an problem thats bugging me..
I have to open a .pdf file at the client side when the user clicks a button..
Opening is not a problem.. I am able to do it using the following code
which is executed when the user clicks on the button
MyFileStream = New FileStream("E:\MyWork\Test\DownloadFiles\Reports\Rpt.pdf", FileMode.Open)
FileSize = MyFileStream.Length
Dim Buffer(CType(FileSize, Integer)) As Byte
MyFileStream.Read(Buffer, 0, CType(MyFileStream.Length, Integer))
MyFileStream.Close()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename=MyReport.PDF")
Response.BinaryWrite(Buffer)
The problem is that the user first sees a 'Open/ Save / Cancel' dialog box. Only when the user clicks on 'Open' does the .pdf file get opened.
My client wants it to be opened directly when the button is clicked.
Am at a loss and any help will be appreciated...
Thanks in advance
Hi ,
R u seaching for something like this.....
String strPop = "<script language='javascript'>" + Environment.NewLine +
"window.open('E:\MyWork\Test\DownloadFiles\Reports\Rpt.pdf"','Report','height=520,width=730,toolbars=no,scrollbars=yes,resizable=yes');" + Environment.NewLine +
"</script>" + Environment.NewLine;
Page.RegisterStartupScript("Pop", strPop);
Hope this will help u
R u seaching for something like this.....
String strPop = "<script language='javascript'>" + Environment.NewLine +
"window.open('E:\MyWork\Test\DownloadFiles\Reports\Rpt.pdf"','Report','height=520,width=730,toolbars=no,scrollbars=yes,resizable=yes');" + Environment.NewLine +
"</script>" + Environment.NewLine;
Page.RegisterStartupScript("Pop", strPop);
Hope this will help u
With Warm Regards,
Sushanth.CP
Sr. Software Engineer
Sushanth.CP
Sr. Software Engineer
![]() |
Similar Threads
- open save dialog box error (PHP)
- Front Page error when opening .HTM file (HTML and CSS)
- open a PDF file in visual basic (Visual Basic 4 / 5 / 6)
- File Dialog window, save dialog window (Python)
- Unable to choose Open or Save when downloading... (Web Browsers)
Other Threads in the ASP.NET Forum
- Previous Thread: Returning Empty Datatable
- Next Thread: Asp.net+xml+ms Sql
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery listbox menu mono mssql multistepregistration nameisnotdeclared news novell objects opera problem redirect registration relationaldatabases reportemail rotatepage security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming





