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

I have code that works to create an Excel file of data presented on my .asp page.

The code automatically downloads the file when I access the page. How do it get it to work only when a link is clicked.

The code I am using is

ASP.NET
<%
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "filename=excelfile.xls"
%>


Thanks
Posted

1 solution

Simply You can do that

HTML
<a href="urlpage"> Download</a>
 
Share this answer
 
Comments
padders01 27-Nov-15 6:37am    
Hi, I tried similar to that, but the page automatically still downloads the Excel file when refreshing
Anil Sharma1983 27-Nov-15 6:54am    
k, try javascript


Download
<script>
function download()
{
location.href = "your_url";
}
padders01 27-Nov-15 8:25am    
Great thanks, I have it working now

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