How to Return a File for the User to Save in an ASP.NET Application?

kingmakreth

New Member
I have one c# control and I am creating an image at runtime. The problem here is how do i open the file dialog when a user creates a submit button.I have tried content-disposition but it is not working :(Here is the scenario:- I have one aspx file in that i have one ascx control file.
  • In that control file's cs file i am doing some rendering and creating one image unique to that user only. After creating that image i want to display it and download it
  • I have one button 'download' declared in control's html file and specified one method in the onclick event of that button
The function specified in onclick is written in cs file of that control. it is as follows:\[code\]public void DownloadPNG(object sender, EventArgs e){ Response.Clear(); Response.ContentType = "text/png"; Response.AddHeader("content-disposition", "attachment; filename=hello.png"); Response.Write("..."); Response.End();}\[/code\]Am I doing right?. Will this call this function? Is this function right?
 
Top