In a grid am having an image button ; on click o to open a file that is there in database.
My code is like this
protected void imgBtnPersonalView_Click(object sender, ImageClickEventArgs e)
{
ImageButton imgBtnPersonalView = (ImageButton)sender;
GridDataItem dataItem = (GridDataItem)imgBtnPersonalView.NamingContainer;
string documentId = dataItem["Document_Id"].Text;
DataTable dt = objNewJoineeFormBL.GetDocumentUploadByDocumentId(documentId);
byte[] objData = (byte[]) dt.Rows[0]["Data"];
string strFileName = dt.Rows[0]["Document_Name"].ToString();
string fileExtension = dt.Rows[0]["File_Format"].ToString();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = fileExtension;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + strFileName);
Response.BinaryWrite(objData);
Response.Flush();
Response.End();
}
I can see the data while debugging..
But when it comes to the last line, it shows an error like
0xc00ce514 - JavaScript runtime error: Could not complete the operation due to error c00ce514
i am attaching screen shot of it.
What i need is, a file window to open/ save button.
i got files in picture format, doc and pdf.
Thanks in advance
My code is like this
protected void imgBtnPersonalView_Click(object sender, ImageClickEventArgs e)
{
ImageButton imgBtnPersonalView = (ImageButton)sender;
GridDataItem dataItem = (GridDataItem)imgBtnPersonalView.NamingContainer;
string documentId = dataItem["Document_Id"].Text;
DataTable dt = objNewJoineeFormBL.GetDocumentUploadByDocumentId(documentId);
byte[] objData = (byte[]) dt.Rows[0]["Data"];
string strFileName = dt.Rows[0]["Document_Name"].ToString();
string fileExtension = dt.Rows[0]["File_Format"].ToString();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = fileExtension;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + strFileName);
Response.BinaryWrite(objData);
Response.Flush();
Response.End();
}
I can see the data while debugging..
But when it comes to the last line, it shows an error like
0xc00ce514 - JavaScript runtime error: Could not complete the operation due to error c00ce514
i am attaching screen shot of it.
What i need is, a file window to open/ save button.
i got files in picture format, doc and pdf.
Thanks in advance