第三方Girdview中文件下载的方法,以及js显示图片

/// <summary>
/// 文件下载事件
/// </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["序号"].ToString().Equals(sellContractScanId)) {
url = dr["路径"].ToString();
name = dr["文件名称"].ToString();
break;
} }
if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(url))) {
Response.Redirect("UserInfoScanDownload.aspx?FilePath=" + url + "&FileName=" + name);
}
else
{ bp.Alert("文件不存在!");
}
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();
}
}
第三方Girdview中文件下载的方法,以及js显示图片的更多相关文章
- ubuntu下使用PIL中的show函数,无法显示图片的问题
问题描述:ubuntu14.04系统,python2.7(version),正在学习python中, from PIL import Image im = Image.open('1.jpg') im ...
- PHP中的__toString方法(实现JS里的链式操作)
_toString方法是在打印对象时自动调用的魔术方法,如果不声明会报以下错 Catchable fatal error: Object of class String could not be co ...
- MVC发布后项目存在于根目录中的子目录中时的css与js、图片路径问题
加载固定资源js与css <script src="@Url.Content("~/Scripts/js/jquery.min.js")" type=&q ...
- JS与OC交互,JS中调用OC方法(获取JSContext的方式)
最近用到JS和OC原生方法调用的问题,查了许多资料都语焉不详,自己记录一下吧,如果有误欢迎联系我指出. JS中调用OC方法有三种方式: 1.通过获取JSContext的方式直接调用OC方法 2.通过继 ...
- iOS之在webView中引入本地html,image,js,css文件的方法 - sky//////////////////////////////////////ZZZZZZZZZZZZZZZ
iOS之在webView中引入本地html,image,js,css文件的方法 2014-12-08 20:00:16CSDN-sky_2016-点击数:10292 项目需求 最近开发的项 ...
- js中的tostring()方法
http://blog.sina.com.cn/s/blog_85c1dc100101bxgg.html js中的tostring()方法 (2013-11-12 11:07:43) 转载▼ 标签: ...
- 秒味课堂Angular js笔记------Angular js中的工具方法
Angular js中的工具方法 angular.isArray angular.isDate angular.isDefined angular.isUndefined angular.isFunc ...
- js中继承的方法总结(apply,call,prototype)
一,js中对象继承 js中有三种继承方式 1.js原型(prototype)实现继承 代码如下: <SPAN style="<SPAN style="FONT-SIZE ...
- JS中通过call方法实现继承
原文:JS中通过call方法实现继承 讲解都写在注释里面了,有不对的地方请拍砖,谢谢! <html xmlns="http://www.w3.org/1999/xhtml"& ...
随机推荐
- 修改Oracle监听端口
修改oracle监听端口 修改端口号的整体步骤:1.1 查看当前监听的状态1.2 停止监听1.3 修改监听文件的端口号1.4 修改初始化参数local_listener1.5 重启 ...
- win8没有无线网络适配器问题
1. 先关闭ssid : 命令提示符(管理员)输入 :netsh wlan set hostednetwork mde=disallow ssid 2. 再设置无线名称和密码 :netsh wlan ...
- python2.7安装scikit-learn遇到的问题及解决方法
安装完matplotlib后,在运行scikit-learn相关的库的时候又遇到缺包的问题,本来以为缺什么包就装什么包,但是由于种种原因,使我走上了弯路: 第一个坑:学校校园网限制.我用scikit- ...
- 看的oracle数据库视频 记的一点笔记
3个默认的用户 sys //网络管理员 权限由上到下降低 [最后加上 as sysdba] system //本地管理员 scott //普通用户 默 ...
- 使用NSJSONSerialization将数组或字典转为字符串
IOS中将数组或字典转为字符串可以用NSJSONSerialization,代码如下: NSData* data = [NSJSONSerialization dataWithJSONObject:a ...
- 例子:Bluetooth app to device sample
本例子演示了: 判断蓝牙是否打开,是通过一个HRsult值为0x8007048F的异常来判断的 catch (Exception ex) { if ((uint)ex.HResult == 0x800 ...
- UliPad ----python 开发利器
安装wxPython ...
- 《2---关于JDBC编程过程中驱动配置问题》
说明:我在Editplus中编写了一个简单的JDBC程序,用来测试是否和数据库连接正确.读者如有其它疑问,可以留言交流. [1]程序如下: import java.sql.*; public clas ...
- Fragment的使用(二)
动态添加Fragment 将MainActivity的布局文件中的两个Fragment的代码注释掉.在MainActivity的java文件中添加如下代码: package com.cm.myfrag ...
- 在linux使用make编译ArduPilot for Pixhawk/PX4 ArduPilot 编译环境搭建
Building ArduPilot for Pixhawk/PX4 on Linux with Make 使用Make编译 ArduPilot for Pixhawk 2, Pixhawk and ...