下面的代码可以实现弹出窗口让用户下载指定的文件,以原文件名来命名。
Page.Response.Buffer=true;
Page.Response.Clear();
Page.Response.ContentType="Application/unknown";
Response.AddHeader("Content-Disposition","attachment; filename=" +
ds.Tables[0].Rows[0]["filename"].ToString() + ";");
Page.Response.BinaryWrite(file);
Page.Response.Flush();
Page.Response.End();
解决方案 »
- 网页关键字的提取
- 局域网内的菜鸟问题,大哥帮帮我
- 用户控件的子控件visible属性的问题
- 对VS2008感兴趣的朋友们不妨近来看看
- 自己写的编码类
- asp.net 2.0 中建立用户后,这些数据被存放在哪里?
- 怎么老出现这个东西!
- 未能创建类型httphandler
- 如何判断用户是否在线?
- js动态删除文本框,删除第二个的,却将文本框里的值挪到第一里去了,把原先第一个文本框里的值删除了
- window.open("fileEdit.aspx?e:\aa.txt")为什么\没有了??有没有在服务端打开一个新的网页的函数??
- hvmenu为什么不能显示在listbox(dropdownlist)控件上面(急!!!)
Response.AddHeader("Content-Disposition","attachment; filename=" +
ds.Tables[0].Rows[0]["filename"].ToString() + ";");
放到page_load中Page.Response.Buffer=true;
Page.Response.Clear();
Page.Response.ContentType="Application/unknown";
Response.AddHeader("Content-Disposition","attachment; filename="test.txt" + ";");string s = "this is a test programe";
byte[] tmp = System.Text.Encoding.Default.GetBytes(s); Page.Response.BinaryWrite(tmp);
Page.Response.Flush();
Page.Response.End();