Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to call for the windows.open java instruction to show an excel or a pdf that I create dinamically from an active.report document, I have try a looootss of response headers and others stuff but nothing seems to work with Ie7, the page blinks for a second and disappear. I can't make any modification on the configuration of the Ie7 'not allowed by the client', or puting the windows.open on the onclick event of the button, because I need to generate the report dinamically first. this works perfect with Ie8 and Ie6, the problem is Ie7. It's been two weeks I've been looking for a solution, I would really appreciate some help. here is the code.

to put it simple, I need to make this line to work in IE7

SQL
Page.ClientScript.RegisterStartupScript(Me.GetType(), "click", "window.open('appData/test.xls','','location=no,resizable=yes,scrollbars=yes');", True)


for the example I´m using a one page simple document, it works in I8 and Ie6, but blink and disappear in I7, the same if I use a pdf. if I try with a txt, works perfect in all browsers.
Posted
Comments
n.podbielski 15-Oct-12 17:52pm    
Are you setting mime type?
OtroCubaLibre 16-Oct-12 10:23am    
Hi, thanks for the response, yes I used "application/pdf" for pdf and "application/vnd.ms-excel" for excel.
Rohit Shrivastava 15-Oct-12 18:16pm    
I can suggest following:

1. Check if IE7 blocking pop-up window for your application.
2. Check if IE7 have mapping for xls to excel to show.
3. Try to give a name to window in window.open. Page.ClientScript.RegisterStartupScript(Me.GetType(), "click", "window.open('appData/test.xls','testxls','location=no,resizable=yes,scrollbars=yes');", True)
4. Check if you get any javascript error on IE7
5. Check using fiddler if request for test.xls is going to server and what response is coming.

That's all I can think of now.
Thanks
Rohit
OtroCubaLibre 16-Oct-12 10:20am    
Hi Rohit, thanks for your quick response, I checked all you suggest me and is the same, no blocking, the mapping is fine, put a name to the window, no javascript errors and install fiddler, this are the headers for the request and the response, can you see something rare in the headers??

Request Headers

POST /.../default.aspx HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*
Referer: http://.../default.aspx
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)
Connection: Keep-Alive
Content-Length: 196
Host: ...
Pragma: no-cache

Response Headers

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 16 Oct 2012 13:52:16 GMT
Content-Length: 583
Rohit Shrivastava 16-Oct-12 10:46am    
I doubt that these request / response headers are for window.open. these seems for the page when it loads. window.open request must be a GET request, it cannot be a POST request for default.aspx. I assume popup window opens when user clicks on some button. If do not see any request for "appData/test.xls" then it means that window.open function is not been executed successfully and its a client side java-script problem.

you can try Response.Write as following :

C#
Response.Write("<script>window.open('YourUrl');</script>");
 
Share this answer
 
Comments
OtroCubaLibre 16-Oct-12 10:29am    
Hi Bhushan, I tried your solution and is the same, in fact in the fiddlers both calls have the same headers.


Response.Write("<script>window.open('appData/prueba.pdf','pruebapdf','location=no,resizable=yes,scrollbars=yes');</script>")

Page.ClientScript.RegisterStartupScript(Me.GetType(), "click", "<script>window.open('appData/prueba.pdf','pruebapdf1','location=no,resizable=yes,scrollbars=yes');</script>")
Ok, now I think, I understood your problem, it is about "Automatic prompting for file download is disable". I assume following is your sequence of action:

1. On a button click, you post back the form
2. Do the processing of generating report (ending up with creating a file on server)
3. Render client side start-up script window.open with the generated file and expects to open file download in another window.

I hope my assumption is correct. Now following are solutions:

1. Instead of rendering window.open, clear the response and stream the file which you created in response which will also allow you to cleanup the file once its rendering is complete. This may result in file downloaded in the same window, but this should not impact anything.

2. Write a custom download handler (custom HttpHandler), quite easy to write. It will generate the file and stream and clean up. Now you can easily use hyperlink with target ="_blank" which will open the file download in new window.

These solution would solve your problem.

Thanks
Rohit
 
Share this answer
 
Comments
OtroCubaLibre 17-Oct-12 14:49pm    
Hi Rohit, thank you very much for the ideas, help me a lot to understand the problem, I finally use the response to render the page, but I needed to be in other window (and I could'n write the download handler), so I added this in the button

OnClientClick="aspnetForm.target ='_blank';setTimeout('fixform()', 50);"

then I used the call with a redirect

Response.Redirect("ShowReport.aspx")

and in the top of the page insert,

function fixform() {
document.getElementById("aspnetForm").target = '';
}
to put back the target of the form to _self.

(this solution I also find it on the web, it's not mine.)
problem solved.
thanks again.
Cubas

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900