如何在C#(WEB页面)中实现弹出一个保存对话框???(有原代码甚好)
    (强调1:是在WEB中 ,不是在WINDOW!!!)
    (强调2:是保存对话框,不是打开对话框!!!)

解决方案 »

  1.   

    use javascriptdocument.execCommand('SaveAs',null,'Docs/something.txt')
    http://msdn.microsoft.com/workshop/author/dhtml/reference/constants/saveas.asp
      

  2.   

    using System.IO;
    FileStream  ...Page.Response ...
    发送响应流来解决.
      

  3.   

    saucer(思归):document.execCommand('SaveAs',null,'Docs/something.txt')是写在前台还是后台??
       'Docs/something.txt'这是个什么东东???
      

  4.   

    it is javascript, on the client side<input type="button" value="click me" onclick="runSave()">
    <script language=javascript>
     function runSave()
     {
        document.execCommand('SaveAs',null,'SomeFileName.txt');
     }
    </script>
      

  5.   

        thank you!
                   能不能 1:把左上角的“保存HTML文档”改成“保存文档”或去掉也行;
                          2:把保存类型改为只显示*.csv一种                (这个问题真的很“变态”)
      

  6.   

    随便找个 Dhtml手册看看便知道了,
      

  7.   

    HTML 编辑器就是用这个原理
      

  8.   

    <html>
    <script Language="javascript">
    function a(){}
    </script>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <title>page-51windows.com</title>
    <style>
    <!--
    body, table, td, div,a { font-family: Verdana; font-size: 10pt; color: #000080 }
    -->
    </style>
    </head>
    <body>
    <object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id="ObjWB" width=0 height=0></object><a href="javascript:void(0);" onClick="document.all.ObjWB.ExecWB(4,1);">Save As </a>
    </body></html>
      

  9.   

    类似于CSDN的这个功能吧!!
    你看这个文件http://community.csdn.net/expert/Xsl/2.xsl
      

  10.   

    还好我是火星来的~~~~
    string path = Server.MapPath(this.xlfile.Text+".xls");System.IO.FileInfo file = new System.IO.FileInfo(path);
    Response.Clear();
    Response.Charset="GB2312";
    Response.ContentEncoding=System.Text.Encoding.UTF8;
    // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
    Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
    // 添加头信息,指定文件大小,让浏览器能够显示下载进度
    Response.AddHeader("Content-Length", file.Length.ToString());// 指定返回的是一个不能被客户端读取的流,必须被下载
    Response.ContentType = "application/ms-excel";// 把文件流发送到客户端
    Response.WriteFile(file.FullName);
    // 停止页面的执行Response.End();