用ASP.NET2.0做的一个网站,其中一个网页中需要有个“下载”按钮(就是普通的Button),点击之后触发事件链接到一个代理页面,代理页面的主要代码如下:   Response.Charset = "utf-8";
   Response.Buffer= true;
   this.EnableViewState = false;
   Response.ContentEncoding = System.Text.Encoding.UTF8;
   Response.ContentType=fileContentType;
   Response.AppendHeader("Content-Disposition","attachment;filename=" + theFileName); 
   Response.WriteFile(filename);    Response.Flush();
   Response.Close();
   Response.End();通过执行这个代理页面,弹出如上图的内容,请问如何可以不用用户选择而直接“打开”文件(文件类型无限制)?怎么操作这个图片上的“打开”按钮?

解决方案 »

  1.   

    你先建一个WORD操作类如:word.appliaction app=new appliaction();
    object noing=System.reclf.missing.value;
    app.open(filename,ref noing,ref noing,ref noing,ref noing,ref noing,ref noing,ref noing,ref noing,ref noing,ref noing,ref noing,ref noing,ref noing);
    app.visible=true;
    ....................]
      

  2.   

    Response.Charset = "utf-8"; 
      Response.Buffer= true; 
      this.EnableViewState = false; 
      Response.ContentEncoding = System.Text.Encoding.UTF8; 
      Response.ContentType=fileContentType; 
      Response.AppendHeader("Content-Disposition","filename=" + theFileName); 
      Response.WriteFile(filename);   Response.Flush(); 
      Response.Close(); 
      Response.End(); 
      

  3.   

    <a href="this.doc">打开文件</a>
      

  4.   

    楼主看5楼的吧,应该符合你的要求了。将 attachment; 去掉。
      

  5.   

    不要用btn的事件,使用文字连接,点击连接,直接打开这个文件就可以了;()内的语句通过数据库查询出来,赋值就可以了!如:<td><label for="ctl00_MainContent_cbxAttachs_0"><a href='#' onclick=javascript:window.open('../../test.aspx?Id=190105c8-4571-47f2-b9b4-1008dd936053&type=ProjectApply')></a></label></td>你试一下!