第三方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"& ...
随机推荐
- The last packet successfully received from the server was 2,926,157 milliseconds ago. The last packet sent successfully to the server was 2,926,158 milliseconds ago. is longer than the server configured value of 'wait_timeout'. 解决办法
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully rec ...
- 利用反射模拟一个spring的内部工作原理
这个简单的案例是实行了登录和注册的功能,没有链接数据库. 在bean中id 是唯一的,id和name的区别在于id不能用特殊字符而name可以用特殊字符,比如:/-\.... package com ...
- hdu 1232, disjoint set, linked list vs. rooted tree, a minor but substantial optimization for path c 分类: hdoj 2015-07-16 17:13 116人阅读 评论(0) 收藏
three version are provided. disjoint set, linked list version with weighted-union heuristic, rooted ...
- 008-Scala主构造器、私有构造器、构造器重载实战详解
008-Scala主构造器.私有构造器.构造器重载实战详解 Scala主构造器实战 无参数的主构造器 分析 1.name 需要赋初值,一般通过占位符来代表空值 2.private 声明私有的age 生 ...
- JavaScript由浅入深(一)——类型、值和变量
JavaScript是一门面向web的.高端的.动态的.弱类型的编程语言,是学习web前端开发必备的基础技能之一.JavaScript最初是一门脚本语言(scripting-language),它 ...
- C#3.0 扩展方法
扩展方法使您能够向现有类型“添加”方法,而无需创建新的派生类型.重新编译或以其他方式修改原始类型.扩展方法是一种特殊的静态方法,但可以像扩展类型上的实例方法一样进行调用.对于用 C# 和 Visual ...
- EXCEL 图表 只在拐点的时候显示数字
EXCEL图表只在折线的拐点显示数值,中间不需要显示.同时往下拐的,显示在上方,往上的显示在下方,这样数值不会挡住线. 首先,做一些模拟数据 因为起点和终点数值必须显示,所以单元格,C2 D2 C19 ...
- adb catlog>d:\log.txt日志级别
W,警告 I,通知 D,调试 E,错误 V, 到最细的日志 功能测试可以看W和E,性能测试I比较有用
- Linux下PHP的完全卸载
如果想把PHP彻底的卸载干净,直接用yum的remove命令是不行的,而需要查看有多少rpm包,然后按照依赖顺序逐一卸载,在网上查了好多,都是通过 "rpm -qa | grep php& ...
- Silverlight behavior(行为) trigger 大全
behavior是超级有用的东西,一定要学会,因为这个就是面向对象编程中的封装.超级重要! 欢迎大家如果有好的效果,可以给我留言,我打算不断的整理这个behavior,希望不久用behavior可以做 ...