RadRichTextBox validate its not empty

2 posts, 1 answers
  1. Medica Developer 1
    Medica Developer 1 avatar
    3 posts
    Member since:
    Dec 2013

    Posted 23 Jan 2014 Link to this post

    Hi


    I'm using a RadRicjTextBox in a WPF with DataBinding and ValidatesOnDataErrors, and I'm trying to add validation to ensure that the user has acutally typed something into the comment



    Here is the XAML snippet...

    <telerik:HtmlDataProvider Grid.Column="1" Grid.Row="3" x:Name="HtmlProvider2"
                  RichTextBox="{Binding ElementName=CommentsRichTextBox}"
                  Html="{Binding Response, Mode=TwoWay,ValidatesOnDataErrors=True}" />
    <telerik:RadRichTextBox Height="92" Grid.Column="1" Grid.Row="3" Margin="2" x:Name="CommentsRichTextBox" />


    But I'm not sure how to validate the contents in my IDataErrorInfo code, I can't just check to see if the Response field is empty, because as soon as you type anything, and then delete it, the field contains all the HTML wrappings.



    Am I missing something or is there a way to do this, I had thought I should try and convert the HTML to Text somehow and then check, but I don't want that to happen with every key press (I'm also not sure how to go about it



    Thanks in advance



    Paul







  2. Answer
    Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 28 Jan 2014 Link to this post

    Hi Paul,

    Thank you for your interest in RadRichTextBox.

    If you are going to accomplish your desired scenario, you should use the IsEmpty property of RadDocument. This way you could check whether the content of the document is empty or not.

    Please take a look at the following code-snippet for a reference:
    if (this.radRichTextBox.Document.IsEmpty != true)
    {
        Document_Has_Content();
    }

    I hope this helps! Let me know how it goes.

    Regards,
    Yancho
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top