| | |
Opening a .pdf file at the clientside without the open/save dialog box
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
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 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal formview gridview gudi iis javascript list listbox menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview unauthorized validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





