asp.net vb编程在数据库中读取文件名添加到listbox中,如何在listbox中实现双击打开下载事件,事件触发后如何编写下载代码!!!!!!请高人指点!!!!

解决方案 »

  1.   

    onclick:
    string strFileName = list.SelectedValue;fi = new System.IO.FileInfo(strFileName);
    Response.Clear();
    Response.ClearHeaders();
    Response.Buffer = false;

    //Response.Charset = "utf-8";
    //Response.ContentEncoding = System.Text.Encoding.UTF8;

    Response.ContentType = ContentType;
    //Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fi.FullName, System.Text.Encoding.UTF8));
    Response.AppendHeader("Content-Disposition", "attachment;filename=" + fi.Name);
    Response.AppendHeader("Content-Length", fi.Length.ToString());
    Response.WriteFile(fi.FullName);
    Response.Flush();
    Response.Close();
      

  2.   

    <ASP:LISTBOX id="ListBox1"   ondblclick="javascript:GoDownLoad();"
    runat="server" Width="152px" Height="126px">
    <ASP:LISTITEM Value="1">A</ASP:LISTITEM>
    <ASP:LISTITEM Value="2">b</ASP:LISTITEM>
    <ASP:LISTITEM Value="3">c</ASP:LISTITEM>
    </ASP:LISTBOX>
      

  3.   

    <SCRIPT language="javascript">
    <!--
     function GoDownLoad()
     {
    var url = "down.aspx?filename="+Form1.ListBox1.value;
    window.open(url);
     }
    //-->
    </SCRIPT>
    然后,down.aspx就用
    lazyfish(呆呆虫) 的代码下载文件。
      

  4.   

    lazyfish(呆呆虫) 的代码不是vb的吧?怎么能在下载时先提示“下载、打开”呢?