01.
protected
void
Page_Load(
object
sender, EventArgs e)
02.
{
03.
int
IDd = (
int
)Session[
"ID"
];
04.
DataTable dtTable = Session[
"download"
]
as
DataTable;
05.
if
(IDd != 0)
06.
{
07.
string
test = dtTable.Rows[IDd - 1][
"Name"
].ToString();
08.
if
(dtTable.Rows[IDd - 1][
"DownloadFile"
] != DBNull.Value)
09.
{
10.
byte
[] file = (
byte
[])dtTable.Rows[IDd - 1][
"DownloadFile"
];
11.
12.
Response.Clear();
13.
Response.Buffer =
true
;
14.
Response.Charset =
""
;
15.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
16.
Response.ContentType =
"application / pdf"
;
17.
Response.AppendHeader(
"Content-Disposition"
,
"attachment; filename="
+ test +
".pdf"
);
18.
Response.BinaryWrite(file);
19.
Response.Flush();
20.
Response.End();
21.
}
22.
else
23.
{
24.
ScriptManager.RegisterStartupScript(
this
,
this
.GetType(),
"Redit"
,
"alert('ไม่มีเอกสารนี้'); window.location='"
+ Request.ApplicationPath +
"applicationform.aspx';"
,
true
);
25.
26.
}
27.
}