Rich TextBox Data

4 posts, 0 answers
  1. Hemanth
    Hemanth avatar
    24 posts
    Member since:
    Mar 2011

    Posted 05 Dec 2012 Link to this post



    Hi,

    I have an application in which I am using RadRichTextBox, everything works fine but I am trying to convert the text entered in this textbox to HTML format. For this I am using HtmlFormatProvider. But the output is not like I want it to be.

    for eg. Suppose I enter text "hello" and convert it, it gives me the following output.

    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
    <html xmlns=\" http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled</title><style type=\"text/css\">\r\n.s_D8D99854 { font-family: 'Verdana';font-style: Normal; } \r\n</style></head><body><p ><span class=\"s_D8D99854\">&nbsp;hello</span></p></body></html>"



    but i dont want all these tags.So  i did this below code


                 HtmlExportSettings exportSettings = new HtmlExportSettings();
                exportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
                exportSettings.StyleExportMode = StylesExportMode.Inline;
                HtmlFormatProvider formatProvider = new HtmlFormatProvider();
                formatProvider.ExportSettings = exportSettings;
                formatProvider.Export(radRichTextBox.Document);


    exportSettings.StyleExportMode = StylesExportMode.Inline;

    This i m getting error

    Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlExportSettings' does not contain a definition for 'DocumentExportLevel' and no extension method 'DocumentExportLevel' accepting a first argument of type 'Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlExportSettings' could be found (are you missing a using directive or an assembly reference?


    Can some pls help me....


  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 07 Dec 2012 Link to this post

    Hello Hemanth,

    The property in question seems to be misspelled. It is actually called StylesExportMode and if you change it everything should work as expected.You can also refer to this help article where the export settings are explained in further detail. 

    I hope this is helpful!
     
    All the best,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Hemanth
    Hemanth avatar
    24 posts
    Member since:
    Mar 2011

    Posted 08 Dec 2012 Link to this post

    thanks Petya for reply,

    You are right...

    can u pls tel how i get entered text in radrichtextbox for ex: "Hello"
    and store that in string

  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 12 Dec 2012 Link to this post

    Hello Hemanth,
    If you wish to export your document and store it in a variable defined in code, you can do that using one of our format providers. If you simply wish to save the contents of the document as plain text, you can use the TxtFormatProvider. On the other hand, if you need the content of the document as rich text and do not have any requirements for a specific format, we usually recommend using the XamlFormatProvider as it is native for the document's structure. You can find code samples in the help article I referenced.
    If, however, you wish to adopt a data-bound scenario, you can refer to our data providers. They basically encapsulate the format providers and allow usage in XAML.
     
    Regards,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top