翻了一天的资料,没找到答案
dim myfile as new System.IO.FileInfo(filename)
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment;filename='aaa.xls'"
mysqlreader.close()
mycon.close() 
Response.AddHeader("Content-Length", cstr(myfile.Length)) 
Response.ContentType = "application/octet-stream" 
Response.WriteFile(myfile.FullName)
Response.end()能够正常下载保存,但是这段程序执行后,页面上的所有其他程序都不灵了,包括按钮事件,超连接等。本来我想在下载结束后提示一下,结果后面的语句也是不会执行,到底怎么解决啊,求各位大哥大姐援手啊。小弟不胜感激

解决方案 »

  1.   

    to:cym40011(萧雨)
    可是我下载完成后还有代码呢,转到其他页面,后面代码也没法执行了呀
      

  2.   

    楼主抱歉,我还想问你的问题,我用你这个方法在保存时,为什么导出后是.aspx文件,必须手工改成xls才行呢?谢谢 ~~
      

  3.   

    哦,这个一开始我也遇到了,关键是一定要指定filename,那就没问题了
      

  4.   

    to:anmeier(三人行) 
    这个我也是新手,期待高手过来吧
      

  5.   

    我也遇到过,好象是attachment的问题,具体原因不明
    改成另一个关键字就ok了
    可是搂主不行,因为xls系统是认识的
    关注一下这个问题开新窗口,
    Dim sScript As String _
                = "<script language='JavaScript'>" _
                & "window.open(""" & sLink & """, ""_top"", ""titlebar=yes,menubar=no,toolbar=no,status=yes,left=0,top=0,width=1024,height=700"", false);</script>"
            oPage.RegisterStartupScript("OpenNewWin", sScript)
      

  6.   

    不用新开窗口,把下载功能放到新的页面即可。a.aspx
    button1_click(...)
    {
    Response.Redirect("b.aspx");
    }b.aspx
    page_load(...)
    {
    //file的路径可以从a获得
    Response.Clear()
    Response.AddHeader("Content-Disposition", "attachment;filename='aaa.xls'")Response.AddHeader("Content-Length", cstr(myfile.Length)) 
    Response.ContentType = "application/ms-excel";
    Response.WriteFile(myfile.FullName)
    Response.end()}
      

  7.   

    下载的页面做一个新的页面打开。执行完后关闭
    page_load()
    {
       .............
      Response.Write("<script>window.close();</" + "script>");
    }
      

  8.   

    use this try:
    Page.RegisterStartupScript
      

  9.   

    Truly(NULL) ( ) 的是正解
      

  10.   

    Truly(NULL) 的方法用在frame中就不行了。我现在也正为这个问题郁闷着呢
      

  11.   

    我在LinkButton的Click事件中先Response.Redirect("b.aspx")
    然后在b.aspx里的page_load(...)
    {
    //file的路径可以从a获得
    Response.Clear()
    Response.AddHeader("Content-Disposition", "attachment;filename='aaa.xls'")Response.AddHeader("Content-Length", cstr(myfile.Length)) 
    Response.ContentType = "application/ms-excel";
    Response.WriteFile(myfile.FullName)
    Response.end()}b.aspx页面关闭后,并没有回到LinkButton的Click事件中,去继续执行Response.Redirect("b.aspx")后面的语句。