<summary>
File Download Events
</summary>
<param name= "Sender" ></param>
<param name= "E" ></param>
protected void Grid_oncopyinsertclick (object sender, EventArgs e) {
LinkButton lbut = sender as LinkButton;
string Sellcontractscanid = Lbut.commandname;
String url = "";
String name = "";
foreach (DataRow dr in Griviewtable.rows) {
if (dr["ordinal"]. ToString (). Equals (Sellcontractscanid)) {
url = dr["path"]. ToString ();
Name = dr["file name"]. ToString ();
Break
} }
if (System.IO.File.Exists (HttpContext.Current.Server.MapPath (URL))) {
Response.Redirect ("Userinfoscandownload.aspx? Filepath= "+ URL +" &filename= "+ name);
}
Else
{BP. Alert ("The file does not exist!") ");
}
BasePage BP = null;
protected void Page_Load (object sender, EventArgs e) {
if (request["FilePath"] = = null)
Return
if (request["FileName"] = = null)
Return
String filerpath = request["FilePath"]. ToString ();
string filename = request["filename"]. ToString ();
if (System.IO.File.Exists (HttpContext.Current.Server.MapPath (Filerpath))) {
Response.ClearHeaders ();
Response.Clear ();
Response.Expires = 0;
Response.Buffer = true;
Response.AddHeader ("Accept-language", "ZH-TW");
String name = System.IO.Path.GetFileName (Filerpath);
System.IO.FileStream files = new FileStream (HttpContext.Current.Server.MapPath (Filerpath), FileMode.Open, FileAccess.Read, FileShare.Read); byte[] bytefile = null;
if (Files. Length = = 0) {
Bytefile = new Byte[1];
}
Else
{
Bytefile = new Byte[files. Length];
}
Files. Read (bytefile, 0, (int) bytefile.length);
Files. Close ();
Response.AddHeader ("Content-disposition", "attachment;filename=" + httputility.urlencode (filename, SYSTEM.TEXT.ENCODING.UTF8)); Response.ContentType = "APPLICATION/OCTET-STREAM;CHARSET=GBK";
Response.BinaryWrite (Bytefile);
Response.End ();
}
}
How to download files in third party Girdview, and JS display pictures