Display word using web handler

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Newface
    New Member
    • Feb 2012
    • 16

    Display word using web handler

    please help me display word document in a page using web handler or any other way available as i have tried like below:

    Code:
    protected void cmdView_Click(object sender, EventArgs e) 
        {     
    //ReadWriteData is a class    
            ReadWriteData rwd = new ReadWriteData(); 
            string sb = rwd.ReadFile(@"C:\Documents and Settings\pa_mukeshk\My Documents\Visual Studio 2008\Execute 1.0.docx"); 
            Session["FileData"] = sb; 
            Response.Redirect("~/HomePages/ViewPage.aspx", true); 
    //ReadWriteData class has below method 
    public string ReadFile(string path) 
        { 
            FileStream fstream = new FileStream(path, FileMode.Open, FileAccess.Read); 
            StreamReader sreader = new StreamReader(fstream, System.Text.Encoding.UTF8); 
            string sr = sreader.ReadToEnd(); 
            return sr; 
        } 
    //on the load of ViewPage.aspx,i have 
    protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!IsPostBack) 
            { 
                string sb = (string)Session["FileData"]; 
                Label lt = new Label(); 
                lt.Text = sb.ToString(); 
                myPanel.Controls.Add(lt); 
            } 
        }
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Word Documents (.doc or .docx files) are opened by Microsoft Word.
    If the web browser has a plugin that knows how to open these documents, then you will be able to open and display it in the web browser. If the web browser does not have a plugin that can open these files, then it will display a dialog window that allows the user to download the file to the computer and use an appropriate application that can open these files (like Word or Open Office).

    -Frinny

    Comment

    • Newface
      New Member
      • Feb 2012
      • 16

      #3
      Is there any possible way out to read the text of ducument and display it with formatting in web page as i have requirement to read word file and show it in a web page,like in naukri.com(when we click at View tab, all the text arranged in same format is displayed).

      Comment

      Working...