Click here to Skip to main content
15,921,371 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
hi all
i created .zip file in webservice and allow user to user to see "OPen , Save , Cancel" window from javascript using this code
JavaScript
function Export_Report_Sucess(result)
{
    window.location.href(result);
}


but when run this , googleCrome and the rest of browsers except IE didn't appear window however the file was downloaded sucessfully

can any one tells me why and how can i solve this
Posted

Hello,

Make sure in your server side code you have following lines to force the file open/save as dialog.
C#
//Add the file name and attachment, to force the open/save dialog to show
Response.AddHeader("Content-Disposition", "attachment;filename="+ FileName.Name);

//Add the file size into the response header
Response.AddHeader("Content-Length", (FileName.Length - startBytes).ToString());

Also suggest you to go through this article here on CodeProject.

Regards,
 
Share this answer
 
Comments
Prasad Khandekar 5-Jun-13 9:25am    
Also suggest you to do the changes in client side script given in Solution by artefakt94.
Hello,

First, window.location.href is not a function.
Use this :
window.location.href = result;
 
Share this answer
 
Comments
Prasad Khandekar 5-Jun-13 9:26am    
Nice. I totally missed it. +5.
NNos2012 6-Jun-13 6:58am    
me too , thanks alot
Ahmed Bensaid 6-Jun-13 9:05am    
You're welcome ;)
This[^] might help you.
 
Share this answer
 
Hi,

you can do one thing.(so that you don't have to face the browser problem.)

When you get the result (eg: .zip file) you can load Popup Window like this.

step 1: Create Div based section in your web page

C#
<div id="dialog" style="display:none">
<![CDATA[<%--  Add File Name with download link -- %>]]>
</div>


Step 2: Write JavaScript to show dialog in popup
C#
function ShowDialog(isValidAddress) {
    $("#dialog").fadeIn(300);
}
function HideDialog() {
    $("#dialog").fadeOut(300);
}


step 3: Call javascript function showDialog from Code behind.

RegisterStarupScript();

Refer this link better idea

http://forum.jquery.com/topic/a-very-simple-popup-box-div[^]

If this will help you then please accept this as answer and vote for this.

Thanks
 
Share this answer
 

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