David H.H.Lee
asked on
Read RTF in asp.net (Persist entered format)
Hi experts,
Good Day! Happy 2010!
I have a doubt that disturbing our team lately regarding the output in RTF format.
Our client need to load RTF file into their existing asp.net site. Our side have researched and noticed a lot of pointer in internet lead us to use editor to display it. But, we can't find any simple editor that solve the mentioned. Most of them giving the solution to prompt the user download the generated RTF(.rtf) file and this is close to client needed, but it should display in site instead of prompt download.
Question:
===============
Is that any technique to display RTF formatted text ONLY in asp.net?
Any link or reference also highly acceptable.
Some attempt:
============
I've come across a simple solution to read the RTF file, but i can't able to persist the entered original formatted input such as "Table","Bold", "Underline",..etc to display out in site nicely. Here is the code:
ASPX
========
<div>
     <asp:FileUpload ID="FileUpload1" runat="server" /><br />
     <asp:Button ID="btnRead" runat="server" Text="Read Word Document" OnClick="btnRead_Click" /><br />
     <asp:TextBox ID="TextBox1" runat="server" Height="373px" TextMode="MultiLine" Width="500px"></asp:TextBo x>
   </div>
Code-behind
============
using Microsoft.Office.Interop.W ord;
protected void btnRead_Click(object sender, EventArgs e)
  {
    ApplicationClass wordApp = new ApplicationClass();
   // Input box is used to get the path of the file which has to be
   // uploaded into textbox.
   string filePath = FileUpload1.PostedFile.Fil eName;
   object file = filePath;
   object nullobj = System.Reflection.Missing. Value;
   // here on Document.Open there should be 9 arg.
 Â
   Document doc = wordApp.Documents.Open(ref file,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj);
   Document doc1 = wordApp.ActiveDocument;
   string m_Content = doc1.Content.Text;
   TextBox1.Text = m_Content;
  Â
   doc.Close(ref nullobj, ref nullobj, ref nullobj);
   wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
  }
Note: C# or vb.net solution is acceptable in this assistance. Any insight to lead us to the solution is highly appreciated.
Thanks.
Regards
David
Good Day! Happy 2010!
I have a doubt that disturbing our team lately regarding the output in RTF format.
Our client need to load RTF file into their existing asp.net site. Our side have researched and noticed a lot of pointer in internet lead us to use editor to display it. But, we can't find any simple editor that solve the mentioned. Most of them giving the solution to prompt the user download the generated RTF(.rtf) file and this is close to client needed, but it should display in site instead of prompt download.
Question:
===============
Is that any technique to display RTF formatted text ONLY in asp.net?
Any link or reference also highly acceptable.
Some attempt:
============
I've come across a simple solution to read the RTF file, but i can't able to persist the entered original formatted input such as "Table","Bold", "Underline",..etc to display out in site nicely. Here is the code:
ASPX
========
<div>
     <asp:FileUpload ID="FileUpload1" runat="server" /><br />
     <asp:Button ID="btnRead" runat="server" Text="Read Word Document" OnClick="btnRead_Click" /><br />
     <asp:TextBox ID="TextBox1" runat="server" Height="373px" TextMode="MultiLine" Width="500px"></asp:TextBo
   </div>
Code-behind
============
using Microsoft.Office.Interop.W
protected void btnRead_Click(object sender, EventArgs e)
  {
    ApplicationClass wordApp = new ApplicationClass();
   // Input box is used to get the path of the file which has to be
   // uploaded into textbox.
   string filePath = FileUpload1.PostedFile.Fil
   object file = filePath;
   object nullobj = System.Reflection.Missing.
   // here on Document.Open there should be 9 arg.
 Â
   Document doc = wordApp.Documents.Open(ref
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj,
                      ref nullobj);
   Document doc1 = wordApp.ActiveDocument;
   string m_Content = doc1.Content.Text;
   TextBox1.Text = m_Content;
  Â
   doc.Close(ref nullobj, ref nullobj, ref nullobj);
   wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
  }
Note: C# or vb.net solution is acceptable in this assistance. Any insight to lead us to the solution is highly appreciated.
Thanks.
Regards
David
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the suggested. But, i've tried this control and the RTF formatted text still not display properly although i've configured the rendermode to RTF format. Any idea? Thanks.
Here is the code:
Open in new window