要求:  1. Asp.net C#语言   2. 文档类型是文本类型.主要为DOC文件..  3. 点击一个超链接或者按钮时,能打开一个窗口,里面就是所选择文件的内容.. (是打开,不是下载或者保存... )  4. 具体代码..  思路.  提醒.  一个都不能少...  5. 谢谢各位..

解决方案 »

  1.   

    txt的就知道怎么做,doc的没试过,
    搂住可以试下把文件做成txt,然后用js引用进来,和小说网一样显示
      

  2.   

    做成txt可能不行.. 因为DOC文件里可能有表格.图形之类的...  谢谢..
      

  3.   

    这跟你用的语言没有关系,跟你的服务器配置有关,让它识别word文档并,试图在客户端去打开。
      

  4.   

    用a标记直接指向文档的地址,如果客户端安装过word就会自动打开文档。
      

  5.   

    使用js启动word.applcation来调用word,然后open你要打开的doc文件,就成了
      

  6.   

     谢谢.. 但我不是想在office word 里打开哦.. 
    怎么配置呢?  能具体说说吗?
      

  7.   


    谢谢.. 能给个代码我试试吗?
    用JS启动word 应该也是调用了word进程吧.. 它的内容是在IE里显示的还是新打开一个word文件再显示的呢?
      

  8.   

    看看这样行吗               if(!Page.IsPostBack)
    {
    Response.Clear();
    Response.ContentType="application/msword";
    Response.WriteFile(Server.MapPath("~/aa.doc"));
    Response.End();
    }
      

  9.   

    或者你可以使用SharePoint解决,通常2003以上版本的office都支持
    function viewWord() 
    {
        var openDocObj; 
        openDocObj = new ActiveXObject("SharePoint.OpenDocuments.2"); // 为了兼容Office XP,可以创建“SharePoint.OpenDocuments.1” 
        openDocObj.ViewDocument("http://10.64.16.15:8088/webdav/12.doc"); 
    }
      

  10.   

    么有安装SharePoint... 也不会让我在服务器上安装...  汗....
      

  11.   

    找到个其它办法.. 把文档转换为HTML   但还是不太符合要求...  //   在此处放置用户代码以初始化页面   
            Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();
            Type wordType = word.GetType();
            Microsoft.Office.Interop.Word.Documents docs = word.Documents;        //   打开文件   
            Type docsType = docs.GetType();
            object fileName = @"D:\Work\安信\Code\InvestmentBank\Repository\2.doc";
            Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { fileName, true, true });        //   转换格式,另存为   
            Type docType = doc.GetType();
            object saveFileName = @"D:\Work\安信\Code\InvestmentBank\Repository\2.html";
            //下面是Microsoft   Word   9   Object   Library的写法,如果是10,可能写成:   
            /*   
            docType.InvokeMember("SaveAs",   System.Reflection.BindingFlags.InvokeMethod,   
              null,   doc,   new   object[]{saveFileName,   Word.WdSaveFormat.wdFormatFilteredHTML});   
            */
            ///其它格式:   
            ///wdFormatHTML   
            ///wdFormatDocument   
            ///wdFormatDOSText   
            ///wdFormatDOSTextLineBreaks   
            ///wdFormatEncodedText   
            ///wdFormatRTF   
            ///wdFormatTemplate   
            ///wdFormatText   
            ///wdFormatTextLineBreaks   
            ///wdFormatUnicodeText   
            docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,
              null, doc, new object[] { saveFileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML });        //   退出   Word   
            wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod,
              null, word, null); 
      

  12.   

    在“HKEY_LOCAL_MACHINE\SOFTWARE\Classes”键值下,保存了各种文件类型的注册信息,以Office文档为例,与文档相关键值如下。
      
      文档类型               键值
      
      Microsoft Excel 7.0 worksheet    Excel.Sheet.5
      
      Microsoft Excel 97 worksheet     Excel.Sheet.8
      
      Microsoft Excel 2000 worksheet    Excel.Sheet.8
      
      Microsoft Word 7.0 document     Word.Document.6
      
      Microsoft Word 97 document      Word.Document.8
      
      Microsoft Word 2000 document     Word.Document.8 
    bitsCN~com
      
      Microsoft Project 98 project     MSProject.Project.8
      
      Microsoft PowerPoint 2000 document  PowerPoint.Show.8
      
      如果我们要修改Word文档的打开方式,,则在“HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.8”下新建一个名为“BrowserFlags”,类型为“REG_DWORD”的子键值,如果设置其值为“8”,则在独立的窗口中打开Word文档,否则在嵌入IE的Word窗口中打开文档。
      
      注:Microsoft Excel 7.0 worksheet稍有不同,应设置BrowserFlags的值为“9”方可在独立的窗口中打开文档。
    【转自www.bitsCN.com】
      

  13.   

    这个没办法控制,如果客户端没安装word,你怎么打开??