C#.net用javascript脚本怎样写下载功能?
来源:百度知道 编辑:UC知道 时间:2024/06/08 20:38:17
在C#.net中实现下载
Response.Write( ); 括号里的javascript脚本应该怎样写?
数据库Soft
列名 SoftID
SoftName
SoftDownload (软件存储路径)
实现功能:当点击不同的软件,实现相对应的软件下载!
Response.Write( ); 括号里的javascript脚本应该怎样写?
数据库Soft
列名 SoftID
SoftName
SoftDownload (软件存储路径)
实现功能:当点击不同的软件,实现相对应的软件下载!
建议你用按钮来控制下载:
<asp:Button ID="Button1" runat="server" CommandArgument="sid"
onclick="Button1_Click" Text="Button" />
将CommandArgument设定为你的SoftID ,用来传送给事件参数
最后在按钮事件中打开新窗口下载
protected void Button1_Click(object sender, EventArgs e)
{
ClientScriptManager CM = this.Page.ClientScript;
string js = "window.open(" + ((Button)sender).CommandArgument + ";)";
CM.RegisterClientScriptBlock(this.GetType(), "softdown", js,true);
}
连接给成地址就可以下载了,