Response.AppendHeader("Content-Disposition", "attachment;filename=nianjian.xls")
 Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312")
 Response.ContentType = "application/ms-excel"
 Response.OutputStream.Write(gifstream.ToArray, 0, gifstream.Length.ToString)
 Response.End()  估计楼主是没有确定文件格式,才不出下载对话框的

解决方案 »

  1.   

    var txt1="ddddddd";
            Response.Clear();
            Response.Buffer = true;
            Response.Charset = "GB2312";
            Response.AppendHeader("Content-Disposition", "attachment;filename=aa.txt");
            Response.ContentType = "application/ms-txt";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            Response.Write(txt1);
            Response.Flush();
            Response.Close();
            Response.End();
      

  2.   

    谢楼上,不是这样的,其实我是想这样的:1,A页面var result=showmodaldialog()打开B页面,同时要拿到B页面相关操作的返回值,
    2,B页面有GridView数据源的绑定,和一些文件的上下载操作,由于showmodaldialog的一些属性致使B页面在刷新动作时又重新打开一个新的窗口,为了防止重新打开B页面,我在B页面的<head>处加了<base target="_self"/>,这样一来就不会在B页面的刷新操作动作上又打开新的B页面了
    3,B页面中的下载文件操作,<base target="_self"/>导致下载窗口无法弹出。我现在要解决的问题就是在B页面中如果有刷新动作不重新打开新的B页面,但可以弹出下载窗口,同时B页面是由A页面showmodaldialog()出来的。
      

  3.   

    下载这个动作是在GridView的一个模板列中的,点击它触发后台CS代码中的事件,(由于文件是以二进制存在数据库中的)后台服务端从数据库中取的数据以后以 Response()....方法下载文件.
      

  4.   

    我现在也遇到这个问题了,<base   target= "_self "/> 去掉又不行,不去掉,下载窗口打不开
    高人来解决一下