Click here to Skip to main content
15,070,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I previously use this code to download a file.

ASP.NET
<asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl='<%# "~/uploads/"+Eval("Name") %>' Text='<%# Eval("Name") %>'>


and now i wanna do the same on button click so i did something like this.

C#
protected void Button1_Click(object sender, EventArgs e)
{
    Response.Write( "~/uploads/"+"Name" );
}



didn't work for me what should i do?
Posted
Updated 25-Mar-12 9:35am
v2

It can be as simple as that, in pure HTML + JavaScript:
HTML
<input type="button" onclick="location='myfile.zip'" value="Download..." />


—SA
   
v2
Comments
Asad_Iqbal 26-Mar-12 1:00am
   
I agree with you dear but i am doing it on button click cause before that i am adding catcha code so i really need that in a way i mentioned.
   
I don't think so that you have to, because you can easily generate such code in APS.NET <% ... %> with parameters such as download file name or button title (value). Besides, it should give you the idea. When ASPX page is rendered, it is pure HTML (maybe with JavaScript), and ultimately will look like that.
--SA

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