Rich text box not displaying HTML text (HtmlDataProvider)

6 posts, 0 answers
  1. Shiv
    Shiv avatar
    9 posts
    Member since:
    Apr 2012

    Posted 03 Jul 2013 Link to this post

    Hi,

    I recently updated the telerik version from 2012.2.912 to 2013.1.403. 
    Previously I implemented  a richtextbox which displays html text using HtmlDataProvider. With the upgrade to new version Im not able to display the html text in the richtextbox anymore. Did anyone come across something similar like this? There has been no code change. Is there something more we need to in the new version?
    here is the snippet of my code :
     <telerik:RadRichTextBox
                                x:Name="BodyViewText"
                                IsSpellCheckingEnabled="False"
                                AcceptsReturn="True"
                                VerticalScrollBarVisibility="Auto"
                                IsReadOnly="True">
                                <telerik:RadRichTextBox.Resources>
                                    <html:HtmlDataProvider
                                        x:Name="HtmlDataProvider"
                                        Html="{Binding Path=DisplayHTML, Mode=TwoWay}"
                                        RichTextBox="{Binding ElementName=BodyViewText}" />
                                </telerik:RadRichTextBox.Resources>
                            </telerik:RadRichTextBox>


    Please help me in this regard.

    Thank you in advance.

  2. CHRISTIAN
    CHRISTIAN avatar
    39 posts
    Member since:
    Nov 2010

    Posted 10 Jul 2013 Link to this post

    I have the same problem now. Any solution?

    Edit:

    I´m not using the RibbonView. This is my XAML:

    <telerik:HtmlDataProvider Html="{Binding ElementName=textbox, Path=Text, Mode=TwoWay}"  RichTextBox="{Binding ElementName=richTextBox}" />
    <telerik:RadRichTextBox x:Name="richTextBox"/>
    <TextBox x:Name="textbox"/>


    If there is some text in the richtextbox and i type something in the normal textbox the text disappears, but thats all.

    If i type something in the richtextbox nothing happens.
  3. DevCraft banner
  4. Shiv
    Shiv avatar
    9 posts
    Member since:
    Apr 2012

    Posted 10 Jul 2013 Link to this post

    I fixed it ! We need to add export settings for the Htmldataprovider

    Here is the snippet.
     <telerik:RadRichTextBox 
                                x:Name="RichText" 
                               Margin="5"
                                HorizontalAlignment="Stretch"
                                IsSpellCheckingEnabled="False"
                                AcceptsReturn="True"
                               IsReadOnly="True"/>
                            <telerik:HtmlDataProvider Html="{Binding EmailTemplate.MacroBody}" RichTextBox="{Binding ElementName=RichText
    }">
                                <telerik:HtmlDataProvider.FormatProvider>
                                    <telerik:HtmlFormatProvider>
                                        <telerik:HtmlFormatProvider.ExportSettings>
                                            <telerik:HtmlExportSettings DocumentExportLevel="Document" StylesExportMode="Inline"/>
                                        </telerik:HtmlFormatProvider.ExportSettings>
                                    </telerik:HtmlFormatProvider>
                                </telerik:HtmlDataProvider.FormatProvider>
                            </telerik:HtmlDataProvider>
  5. CHRISTIAN
    CHRISTIAN avatar
    39 posts
    Member since:
    Nov 2010

    Posted 11 Jul 2013 Link to this post

    Yayyyy it works thanks!
  6. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 11 Jul 2013 Link to this post

    Hello,

    RadRichTextBox loads the format providers using MEF. One of the changes that was recently done regarding the data providers is that they now use the format provider that is cached by MEF and do not create another instance. That is why if your application uses library caching for example, MEF will not be able to load the format provider and the data providers will not work. 

    In a nutshell, you can add the HtmlFormatProvider in XAML as you have done (it is not required to create export settings, if no customizations will be applied). Another option would be to register the format provider like this:

    DocumentFormatProvidersManager.RegisterFormatProvider(new HtmlFormatProvider());

    or you could also adopt the approach explained in this article. The solution proposed in the documentation will also address issues related to dialogs and pop-ups not being loaded and not being available to use.

    I hope this helps!

    Regards,
    Iva Toteva
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  7. Tony
    Tony avatar
    4 posts
    Member since:
    Mar 2013

    Posted 28 Aug 2014 in reply to Iva Toteva Link to this post

    Iva,

    I have recently run into this problem with 2013.2.827.45 Telerik libraries (and  2014.2.617.45 libraries) with a WPF solution that embeds the Telerik libraries inside my application.  I have the HtmlFormatProvider in XAML as you state but that does not work.  I had to use one of your other options.  I used the following code in the constructor of the view that contains the RadRichTextBox:

    public Foo()
    {
        RadCompositionInitializer.Catalog =
    new TypeCatalog(typeof (HtmlFormatProvider));
        InitializeComponent();
    }

    Doing this got the RadRichTextBox to show my Html content. 

    Note:  The RadRichTextBox and Html content would also work as advertised when I would not embed the Telerik libraries. 

    Hope this helps others in the same boat.
Back to Top
DevCraft banner