<a>超链接实现下载,普通文件只是打开,特殊后缀的文件无法下载,怎么能让所有的文件都是呈下载,不用打开 我那个onclick这里错的 该怎么写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public void downloadfile(string s_fileName) { HttpContext.Current.Response.ContentType = "application/ms-download"; string s_path = HttpContext.Current.Server.MapPath("~/System/DataBackUp/") + s_fileName; System.IO.FileInfo file = new System.IO.FileInfo(s_path); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream"); HttpContext.Current.Response.Charset = "utf-8"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8)); HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString()); HttpContext.Current.Response.WriteFile(file.FullName); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.End(); } <asp:linkbutton ..... <a >超链接里面如何触发 <asp:LinkButton ID="LinkButton1" runat="server"></asp:LinkButton>你换成服务器控件就可以了在加一个后台事件 <a href="down.aspx?path=<%# Server.UrlEncode(Eval("url").ToString())">下载</a>down.aspx.cs里写下载代码 Server.UrlEncode 可以直接传值过去吗? <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click" srcurl='绑定URL值'></asp:LinkButton>后台 protected void LinkButton1_Click(object sender, EventArgs e) { LinkButton lb = sender as LinkButton; string URL = lb.Attributes["srcurl"].ToString(); } Server.UrlEncode 可以直接传值过去吗?Server.UrlEncode是转义URL中的特殊字符,如中文,双引号等 Server.UrlEncode 可以直接传值过去吗?Server.UrlEncode是转义URL中的特殊字符,如中文,双引号等我是后台拼接字符串的下面两个是不是都错的?<a href=\"Down.aspx?path=<%=Server.URLEncode(Eval(\"" + path + "\").ToString())%>\"><a href=\"Down.aspx?path=<%=Server.URLEncode(Eval(\"" + path + "\").ToString())\">这样弄Down.aspx怎么接值啊 string path = Request.QueryString["path"].ToString();接过来为什么都是带<%= 是不是不应该这么接? 后台页面布局怎么做不用TABLE 两个问题!!!急啊!!!!大侠们帮帮忙!!! [asp.net]这些方法有什么用?是做什么的 Javascript 访问页面元素的问题 about package of asp.net application 分布式存储过程求教 怎样时用用户控件中的事件 关于在WinForm嵌入WebForm中的一个简单问题 请大家帮个忙 请大虾帮忙,有关Session的问题? JQuery-Ajax技术 事件触发、无刷新 aspx页面输出是 json格式,请问最后 我得到的页面是 json,还是字符串啊
public void downloadfile(string s_fileName)
{
HttpContext.Current.Response.ContentType = "application/ms-download";
string s_path = HttpContext.Current.Server.MapPath("~/System/DataBackUp/") + s_fileName;
System.IO.FileInfo file = new System.IO.FileInfo(s_path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream");
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.WriteFile(file.FullName);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.End();
}
<asp:linkbutton .....
<a >超链接里面如何触发
Server.UrlEncode 可以直接传值过去吗?
后台
protected void LinkButton1_Click(object sender, EventArgs e)
{
LinkButton lb = sender as LinkButton;
string URL = lb.Attributes["srcurl"].ToString();
}
Server.UrlEncode 可以直接传值过去吗?
Server.UrlEncode是转义URL中的特殊字符,如中文,双引号等
Server.UrlEncode 可以直接传值过去吗?
Server.UrlEncode是转义URL中的特殊字符,如中文,双引号等我是后台拼接字符串的下面两个是不是都错的?
<a href=\"Down.aspx?path=<%=Server.URLEncode(Eval(\"" + path + "\").ToString())%>\"><a href=\"Down.aspx?path=<%=Server.URLEncode(Eval(\"" + path + "\").ToString())\">这样弄Down.aspx怎么接值啊 string path = Request.QueryString["path"].ToString();
接过来为什么都是带<%= 是不是不应该这么接?