protected void DownloadFile(object sender, EventArgs e) { try { string filePath = (sender as LinkButton).CommandArgument; Response.ContentType = ContentType; Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(filePath)); Response.WriteFile(filePath); Response.End(); } catch (Exception ex) { Log(ex.Message, ex.StackTrace); } }
protected void lnkDownload_Click(object sender, EventArgs e) { LinkButton lnkbtn = sender as LinkButton; GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow; string filePath = gvDetails.DataKeys[gvrow.RowIndex].Value.ToString(); Response.ContentType = "image/jpg"; Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\""); Response.TransmitFile(Server.MapPath(filePath)); Response.End(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)