i am trying to open the downloaded file from database in a new browser window..
here is code that i tried..
result = objBL.GetLetter(LetterID, refNo, attachmentType);
if (result != null && result.Rows.Count > 0)
{
DataRow dr = result.Rows[0];
string fileName = dr["FileName"].ToString();
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(fileName));
Response.WriteFile(Server.MapPath("~/Attachments/" + fileName));
Response.End();
}
is there any syntax to open in jquery?
The code you provided isn't jQuery, it's C#. This question actually has nothing to do with jQuery, so please be mindful not to add irrelevant tags to your question next time :).
To open a (downloaded) file in the browser, set the
Content-Disposition
header for yourResponse
object toinline
. Currently, you are setting it toattachment
which forces it to be downloaded as a file instead of being displayed in the browser.Example: