Dec 05, 2008, 5:44 AM
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.
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.
<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
{
}
}