HTML Format

7 posts, 0 answers
  1. Pablo Tola
    Pablo Tola avatar
    43 posts
    Member since:
    Nov 2007

    Posted 07 Feb 2011 Link to this post

    I'm binding a richtextbox to a viewmodel property, not exporting.
    I need to format the output HTML, I don't want the document declaration and I don't want style sheets, I want the styles inline.
    How do I get access to the formater to setup those options?

  2. Ivailo Karamanolev
    Ivailo Karamanolev avatar
    276 posts

    Posted 08 Feb 2011 Link to this post

    Hello Pablo Tola,

    Using the following declarations
    you can declare the data provider like this and it will use DocumentExportLevel=Fragment. You can also customize the HtmlExportSettings any other way you want.
    <telerikHtml:HtmlDataProvider x:Key="dataProvider" RichTextBox="{Binding ElementName=richTextBox}">
                    <telerikHtmlMain:HtmlExportSettings DocumentExportLevel="Fragment" />

    Kind regards,
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. Animesh Dey
    Animesh Dey avatar
    24 posts
    Member since:
    Jul 2012

    Posted 19 Oct 2011 Link to this post

    Hi Ivailo Karamanolev,
    I faced a problem when radtextbox is inside DataTemplate.  DocumentExportLevel="Fragment" is not working on that situation.
        <telerikHTML:HtmlDataProvider  Name="dp1" Html="{Binding HtmlText, Mode=TwoWay}" RichTextBox="{Binding ElementName=txtChat}">
                        <telerikHtmlMain:HtmlExportSettings DocumentExportLevel="Fragment"/>
        <my:RadRichTextBox x:Name="txtChat"></my:RadRichTextBox>
    public class ViewModel : INotifyPropertyChanged
           #region Property(s)
           private readonly DelegateCommand<object> _addCommand;
           public ICommand AddCommand
               get { return _addCommand; }
           string htmlText;
           public string HtmlText
               get { return htmlText; }
                   if (htmlText != value)
                       htmlText = value;
           private ObservableCollection<ChatItem> _ChatItems;
           public ObservableCollection<ChatItem> ChatItems
               get { return _ChatItems; }
               set { _ChatItems = value; OnPropertyChanged("ChatItems"); }
           #region Constructor(s)
           public ViewModel()
               _addCommand = new DelegateCommand<object>(OnAddClick);
               this.ChatItems = new ObservableCollection<ChatItem>();
               ChatItems.Add(new ChatItem() { Message = "Hello" });
           private void OnAddClick(object agrs)
               var html = this.ChatItems[0].Message;
           #region INotifyPropertyChanged
           public event PropertyChangedEventHandler PropertyChanged;
           private void OnPropertyChanged(string propertyName)
               if (this.PropertyChanged != null)
                   this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
       public class ChatItem : INotifyPropertyChanged
           private string _message;
           public string Message
               get { return _message; }
               set { _message = value; OnPropertyChanged("Message"); }
           #region INotifyPropertyChanged
           public event PropertyChangedEventHandler PropertyChanged;
           private void OnPropertyChanged(string propertyName)
               if (this.PropertyChanged != null)
                   this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

    Would you please show me a way....
  4. Boby
    Boby avatar
    637 posts

    Posted 25 Oct 2011 Link to this post

    Hello Animesh Dey,
    Document export level in data template works as expected at our side. You can read more about the various ways to customize the export in our help section.
    If  you continue to experience problems, please send us (through a support ticket) sample project that demonstrates the problem, so we can investigate it further.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Birgit
    Birgit avatar
    19 posts
    Member since:
    Apr 2016

    Posted 26 May 2016 Link to this post


    I've the same problem.

    When i have a radrichtextbox inside a DataTemplate (RadDataForm) the  HtmlImportSettings from HtmlDataProvider is not working.

            <DataTemplate x:Key="MyTemplate">
                    <telerik:DataFormDataField  Label="First Name" DataMemberBinding="{Binding FirstName, Mode=TwoWay}" />
                    <telerik:DataFormDataField  Label="Last Name" DataMemberBinding="{Binding LastName, Mode=TwoWay}" />
                    <telerik:HtmlDataProvider x:Name="htmlDataProvider" RichTextBox="{Binding ElementName=richTextBox}" Html="{Binding HtmlBody, Mode=TwoWay}">
                                    <telerik:HtmlImportSettings  UseDefaultStylesheetForFontProperties="True" />
                                    <telerik:HtmlExportSettings DocumentExportLevel="Fragment"
                    <telerik:RadRichTextBox x:Name="richTextBox"/>
        <telerik:RadDataForm x:Name="DataForm1"
                             ReadOnlyTemplate="{StaticResource MyTemplate}"
                             EditTemplate="{StaticResource MyTemplate}"
                             NewItemTemplate="{StaticResource MyTemplate}">

    Same code without RadDataForm works perfect.

    Did you have a workaround for this problem?

    Kind regards


  6. Petya
    Petya avatar
    983 posts

    Posted 31 May 2016 Link to this post

    Hello Bigi,

    Upon further investigation, it looks like this behavior comes from the WPF framework although I have not been able to isolate the exact cause. This explanation on stackoverflow and the Dependency Property Value Precedence topic on MSDN suggest that dependency properties in data templates might fall back to their default value unexpectedly. The workaround provided in the conversation to place the control along with the provider in a UserControl seem to resolve this, so I'd suggest trying it out.

    I hope this helps.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  7. Birgit
    Birgit avatar
    19 posts
    Member since:
    Apr 2016

    Posted 11 Jul Link to this post

    My workaround is:  do not use RadDataForm.

    I have built my own control for the navigation and action buttons.

Back to Top