Solved

Problems doing a response.BinaryWrite(ImageData) from a Modal Page

Posted on 2006-11-13
6
1,283 Views
Last Modified: 2009-02-06
I have created a page that displays documents from a SQL db table and is opened in a Modal Page. I am trying to do a response.BinaryWrite(ImageData) to view the document.

I have done this in 1.1 and it worked correctly. But now in 2.0 and in a modal window it seems to just hang. I have added <base target="_self"/> to the design side. I have not found a solution to this problem. Does anyone know of any solutions to this? Thanks, all.
0
Comment
Question by:MNDOC
  • 3
6 Comments
 
LVL 10

Expert Comment

by:jnhorst
ID: 17932123
What kind of document is it?  You may need to set the Response.ContentType = "..." such that the ContentType matches the kind of document you are writing.

John
0
 
LVL 1

Author Comment

by:MNDOC
ID: 17932375
From what I can tell, it seems to be a problem with <base target="_self"/>. If I remove this, the binaryWrite will work. But then the modal page links don't wire up correctly. So I need the <base target="_self"/>. Any suggestions? Thanks, again.
0
 
LVL 1

Author Comment

by:MNDOC
ID: 17932419
John,
My code looks like this
I get FileName, ContentType, ImageData from a call to the db. Then return it to the page and use it in the following.

Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition", "attachment; filename=" + FileName)
Response.ContentType = ContentType
Response.BinaryWrite(ImageData)
0
 
LVL 1

Author Comment

by:MNDOC
ID: 18040384
Figured out what I needed to do.
To work, I needed to open the displayfile page in a new window. So basically I needed to add .target = "_top" which would open up the page with the following code in a new window.

Also, I needed the following, it would not work without the clearheaders().

Response.BufferOutput = True
Response.ClearHeaders()
Response.AddHeader("content-disposition", "attachment; filename=" + FileName)
Response.ContentType = ContentType
Response.BinaryWrite(ImageData)

I have not found a better solution than having to open the code in a new window.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18077180
PAQd, 125 points refunded.

DarthMod
CS Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net bundle 8 47
creating a flowchart from an algorithm 5 30
New to Angular (read tutorial) - How do I bind to this table? 11 45
Cannot upload files above 1mb IIS7 11 39
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now