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:
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();
}
Am I doing right?. Will this call this function? Is this function right?
Try using Response.WriteFile
or Response.TransmitFile
or even Response.BinaryWrite
.
You've really given no information to figure out what you are doing.
However, if you want to make a content download as a file from an ASP.NET web page, here's an article I wrote that shows how to do just that.
精彩评论