So I'm asking again.
I am using .Net 1.1 on a Windows XP Pro.
What I want is for the browser to display a PDF "inline" in the browser
in a "new" window. The PDF comes from a database and I stream it to the
browser. The key points are "inline" and "new window". My code works
but it displays the PDF in the current window.
Here is an example. This code is executed on a button click on the
server. When I remove the comments, the browser displays junk. I would
like it to display my document in a new window. Any ideas on how I can
get this to work?
Thank you
Barry
' Response.BufferOutput = True
' Response.ClearHeaders()
' Response.ClearContent()
' Response.ContentType = "text/plain"
' Response.AddHeader("Content-Type", "text/plain")
' Response.Write("<script
language=""javascript"">window.open()</script>")
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "inline; filename=cv.pdf")
Response.AddHeader("Content-Type", "application/pdf")
Response.WriteFile(myCV.ToString())
Response.Flush()
Response.Close()
Barry
var win=window.open("MyGetPDFPage.aspx?PDFID=xxx","PDFWindow");
win.focus();
<bbuls...@hotmail.com> wrote in message
news:1136898928.8...@g49g2000cwa.googlegroups.com...
I still don't understand though. I have posted bits of my Page_Load and
button click procedures. Where exactly do I add your Javascript to open
the new window for each document.
Your code is below.
> var win=window.open("MyGetPDFPage.aspx?PDFID=xxx","PDFWindow");
> win.focus();
Here is my code for "WebForm2.aspx". As it is now it works and
retrieves 11 (although the number changes) documents from an Access
database. It displays 11 buttons on the page. When I click on the 4th
button, I get the 4th document as a PDF in the same browser window. I
would like this to be in a new browser window.
Thank you for your patience.
Barry
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim b As Button
Dim i as Integer
For i As 0 To getCVCount() - 1
b=New Button()
b.Text=BUTTONNAMES(i)
Session.Add("cv" + b.GetHashCode.ToString(),getCVfromDB(i))
AddHandler b.Click, AddressOf buttonClick
Next i
End Sub
Private Sub buttonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim myCV As Object
myCV=Session.Item("cv"+sender.GetHashCode().ToString());
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "inline; filename=cv.pdf")
Response.AddHeader("Content-Type", "application/pdf")
Response.WriteFile(myCV.ToString())
Response.Flush()
Response.Close()
End Sub
So, in the first page, you may have code like this (C#):
private void Page_Load(....)
{
if (!Page.IsPostBack)
{
//Attach client side code to the button(s), so clicking it would
open a new window
btnPDF.Attributes.Add("onclick","OpenNewWindow('PDF');return
false;");
btnDOC.Attributes.Add("onclick","OpenNewWindow('DOC');return
false;");
}
}
Then in the page's HTML view, add following javascript to <Header> section
<Script Language="javascript">
function OpenNewWindow(fileType)
{
var win;
switch(fileType)
{
case "PDF"
win=window.open("GetPDF.aspx","NewWindow");
break;
case "DOC"
win=window.open("GetDOC.aspx","NewWindow");
break;
.......
}
win.focus();
}
</Script>
You can see here, you may have one or more aspx pages that is opened in new
window and requests the pdf (or other files).
<bbuls...@hotmail.com> wrote in message
news:1136904777.6...@z14g2000cwz.googlegroups.com...