Wednesday, March 28, 2012

View PDF in ATLAS?

In my existing 1.1 app, I have a datagrid with a column that, when clicked, displays a pdf file. In trying to convert it to 2.0 with Atlas, the pdf will not display, no error, but no display either. The data for the pdf is stored in SQL as binary data. I have listed the code below. If anyone could shed some light onto the issue, I'd greatly appreciate it.

If dr.Read Then
Dim byData(dr.GetBytes(0, 0, Nothing, 0, Integer.MaxValue) - 1) As Byte
dr.GetBytes(0, 0, byData, 0, byData.Length)
Response.ClearContent()
Response.ClearHeaders()
Response.Buffer = True
Response.AddHeader("Content-Disposition", "inline;filename=" & strFileName)
Response.AddHeader("Accept-Header", byData.Length)
Response.ContentType = strContentType
Response.BinaryWrite(byData)
Response.Flush()
Response.Close()
End If

Again, any feedback would be appreciated.

Thanks.

I ended up diong the postback in a different page.

What you will need to do is have a link in your datagrid to another page (ie viewattachment.aspx?filename=filename) and then create a non ajax windows form page called viewattachment.aspx

In the viewattachment.aspx page_load method you can then place your response code as you mentioned above

I have written an example of thishere.
Clinton

No comments:

Post a Comment