首页 新闻 会员 周边 捐助

关于下载的问题

0
悬赏园豆:10 [已关闭问题]
<P>我用&lt;a href='../&lt;%# Eval("url") %&gt;'&gt;下载&lt;/a&gt;做个下载的功能</P> <P>现在问题是 如果是图片或者.txt文件的话&nbsp; 它会直接在另一个浏览器窗口内打开</P> <P>我想统一成弹出提示下载的对话框 该么样改啊?</P> <P>但是我又不想做成按钮点击 ?</P>
问题补充: 我要做成的只是一个<A>标签的链接 并不想做成按钮事件啊
yeyang的主页 yeyang | 菜鸟二级 | 园豆:418
提问于:2008-04-15 17:29
< >
分享
其他回答(1)
0
你愿意做成把文件的内容写到数据库的吗? 用这个控件: <asp:FileUpload ID="FileUpload" runat="server" Width="437px" /> //In model.FileName = this.FileUpload.FileName; model.FileContent = this.FileUpload.FileBytes; model.FileType = this.FileUpload.PostedFile.ContentType; //Out 在把文件名给展现出来的旁边多个按钮 protected void lbtnFile_Click(object sender, EventArgs e) { InformInfo model = _facade.GetModel(Convert.ToInt32(this.lblId.Text)); Response.Buffer = true; Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.FileName)); Response.AddHeader("Content-Type", model.FileType); Response.BinaryWrite(model.FileContent); Response.End(); }
迭_戈 | 园豆:147 (初学一级) | 2008-04-15 18:01
0
<div onclick=\"OpenObject('" + Server.UrlEncode(URL) + "')\"><a>" + FileName + "</a></div> private void openFile() { string FilePath = Server.MapPath(FileURL); FileInfo fi = new FileInfo(FilePath); FileStream fs = new FileStream(FilePath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fi.Name, System.Text.Encoding.UTF8).Replace("+", " ")); Response.BinaryWrite(bytes); Response.End(); } openFile()可以在页面回调加以区别后调用
AndyFish | 园豆:1575 (小虾三级) | 2008-04-16 13:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册