web页面中点击下载跳出保存、打开窗体
2009-12-24 15:56
330 查看
//事件
filepath = Request.PhysicalApplicationPath + @"Up_Load/SaveFile";
cFile(GridView1.Rows[e.RowIndex].Cells[2].Text.ToString());
//封装方法
private void cFile( string carg)
{
FileLoad(this.CurrentDirectory, carg);
}
public void FileLoad(string filepath, string argStr)
{
string filename = Path.Combine(filepath, argStr);
//设置返回类型
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
//对文件名做标准编码
string Encodefilename = System.Web.HttpContext.Current.Server.UrlEncode(argStr);
Encodefilename = Encodefilename.Replace('+', ' ');
//下载文件提示
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + Encodefilename);
System.Web.HttpContext.Current.Response.TransmitFile(filename);
System.Web.HttpContext.Current.Response.End();
}
string filepath = "";
string CurrentDirectory
{
get
{
string Vfilepath = this.ViewState["CurrentDirectory"] as string;
if (string.IsNullOrEmpty(Vfilepath))
{
Vfilepath = this.filepath + @"/" + depart + @"/";
}
return Vfilepath;
}
set
{
this.ViewState["CurrentDirectory"] = value;
}
}
filepath = Request.PhysicalApplicationPath + @"Up_Load/SaveFile";
cFile(GridView1.Rows[e.RowIndex].Cells[2].Text.ToString());
//封装方法
private void cFile( string carg)
{
FileLoad(this.CurrentDirectory, carg);
}
public void FileLoad(string filepath, string argStr)
{
string filename = Path.Combine(filepath, argStr);
//设置返回类型
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
//对文件名做标准编码
string Encodefilename = System.Web.HttpContext.Current.Server.UrlEncode(argStr);
Encodefilename = Encodefilename.Replace('+', ' ');
//下载文件提示
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + Encodefilename);
System.Web.HttpContext.Current.Response.TransmitFile(filename);
System.Web.HttpContext.Current.Response.End();
}
string filepath = "";
string CurrentDirectory
{
get
{
string Vfilepath = this.ViewState["CurrentDirectory"] as string;
if (string.IsNullOrEmpty(Vfilepath))
{
Vfilepath = this.filepath + @"/" + depart + @"/";
}
return Vfilepath;
}
set
{
this.ViewState["CurrentDirectory"] = value;
}
}
相关文章推荐
- Web开发之用canvas2image.js将canvas保存为图片(实现页面截图下载功能)
- ASP.Net Web 点击链接直接下载 不在浏览器打开
- android webview页面中的文件(apk,mp3或mp4,以及文本等)链接,选择被打开还是直接下载
- 点击网页中PDF链接时,打开PDF文档不再是直接IE查看,而是提示下载保存
- 【JS】点击页面判断是否安装app并打开,否则跳转下载的方法
- [Web 开发] 定制IE下载对话框的按钮(打开/保存)<收藏>
- Web页面打开新的窗体之window.showModalDialog和window.open
- jsp页面点击链接下载文件,跳出另存为
- ionic 实现 应用内(webview中html页面点击) 和 应用外 (浏览器html页面点击) 打开本地安装应用
- PHP实现点击a标签的href做链接时,直接保存文件(任何类型),而不是通过浏览器直接打开下载的文件
- [Web 开发] 定制IE下载对话框的按钮(打开/保存)
- JAVA打包xml成zip保存在服务器任意位置,并能在页面进行点击下载
- [Web 开发] 定制IE下载对话框的按钮(打开/保存)
- [Web 开发] 定制IE下载对话框的按钮(打开/保存) 推荐
- mui webview选项卡 首次只加载首页,点击触发打开页面
- JavaScript弹出新的页面,像在web迅雷首页点击某一下载文件名时弹出的新页面(窗体)
- [Web 开发] 定制IE下载对话框的按钮(打开/保存)
- webView点击打开其他的页面iOS
- Web 开发] 定制IE下载对话框的按钮(打开/保存)(转)
- .Net web :点击button后台打开新页面