-
File download
hi,
i have download the file from particulat location. i wrote the code using asp.net button click event, its working fine. but coolite button click event , the same code does not working. what is the problem. i got error Status code: 200 Status text: BADRESPONSE: Syntax error.
Code:
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<ext:button ID="Button2" runat="server" AutoPostBack="false">
<AjaxEvents>
<Click OnEvent="Button1_Click1">
</Click>
</AjaxEvents>
</ext:button>
protected void Button1_Click(object sender, EventArgs e)
{
FileInfo file = new FileInfo(Server.MapPath("Chap0101.pdf"));
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
// Response.ContentType = "application/octet-stream";
Response.ContentType = "application/pdf";
Response.WriteFile(file.FullName);
Response.End();
}
else
{
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
FileInfo file = new FileInfo(Server.MapPath("Chap0101.pdf"));
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/pdf";
Response.WriteFile(file.FullName);
Response.End();
}
else
{
}
}
-
RE: File download
Hi,
At this moment you can't download file during AjaxEvent because it brakes AjaxEvent. But functionality which you try to implement can be useful therefore I'll try to resolve it today/tomorrow