This is a migrated thread and some comments may be shown as answers.

RadRichTextBox validate its not empty

1 Answer 81 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Medica Developer 1
Top achievements
Rank 1
Medica Developer 1 asked on 23 Jan 2014, 06:03 PM

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







1 Answer, 1 is accepted

Sort by
0
Accepted
Missing User
answered on 28 Jan 2014, 01:50 PM
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 >>
Tags
RichTextBox
Asked by
Medica Developer 1
Top achievements
Rank 1
Answers by
Missing User
Share this question
or