Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET RichTextBox
Hi All,
 
how to read word file into richtextbox or in textbox using asp.net in c#
 
Regards,
VenkateshDesai.
Posted 20-Sep-12 3:56am
Comments
ridoy at 20-Sep-12 13:13pm
   
do you want to load the contents of word file in richtextbox?If so then i say it is possible,it do it a couple of days ago in a small work
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Below link works for windows application, see if you can use for web application:
Read MS word using C#[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You don't.
 
The TextBox control is just a normal HTML TextBox and doesn't know anything about Word documents so it can't display them.
 
ASP.NET doesn't have a RichTextBox control and even if it did, it has the same problem as the TextBox. It wouldn't know about the Word document format.
 
Now, I'm not saying it's impossible. You would have to use a 3rd party control to display the Word document. Most don't support Word so you'll have to do some research and find one that does.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try Using 3rd Party Controls like Telerik or DevExpress
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Use Open Xml SDK[^]. It's free, you don't need any Office libraries and there are many resources on the web.
Take a look at Read Microsoft Word Document File by using C#[^].
 
--Amit
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hi Venkatesh Desai,
 
I hope this code will helpful for you.
Microsoft.Office.Interop.Word.ApplicationClass Application =  new Microsoft.Office.Interop.Word.ApplicationClass();
            object nullobj = System.Reflection.Missing.Value;
            object file = Server.MapPath("CV.docx");
            object value = System.Reflection.Missing.Value;
            Microsoft.Office.Interop.Word.Document doc = Application.Documents.Open(ref file,ref nullobj, ref nullobj, ref nullobj,ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,ref value,ref value,ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
 
            doc.Activate();
            //var ss = doc.Words[0];  
            var x = doc.Words;
            cn.Open();
            SqlCommand cmd = new SqlCommand("SELECT DISTINCT SkillId FROM tblSkills ORDER BY SkillId", cn);
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            string SkillName = "";
            string SetSkills = "";
            string FetchSkill = "";
            
            if (ds.Tables[0].Rows.Count > 0)
            {
                string Doc_Content = doc.Content.Text;
                for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                {
                    SkillName = ds.Tables[0].Rows[i]["SkillId"].ToString();                    
                    if (Doc_Content.ToString().IndexOf(SkillName) > 0)
                    {
                        SetSkills += SkillName + ",";
                    }
                    
                }
            }
 
            cn.Close();
            
            txtResult.Text = SetSkills.TrimEnd(',').ToString();
            // txtContent.Text = Doc_Content;
            doc.Close(ref nullobj, ref nullobj, ref nullobj);
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,725
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,589
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100