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

Validation and NotifyOnValidationError

3 Answers 167 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Kirk Quinbar
Top achievements
Rank 1
Kirk Quinbar asked on 15 Dec 2010, 05:26 PM
Since the RadRichTextBox can't be bound directly to a viewmodel (or whereever) and has to go through one of your dataformatters (html, txt) does this mean it doesnt support the standard validation interface that is built into silverlight. I tried adding NotifyOnValidationError=True to the binding i have, but nothing propagates up to the UI upon an error being thrown to the binding. Same code works on a regular textbox, so I am assuming that because you have this intermediate step of binding to a dataprovider, that it won't work?

or if there is a way to do this, please provide a sample project.

Kirk

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 21 Dec 2010, 08:24 AM
Hello Kirk Quinbar,

RadRichTextBox uses DataProviders to utilize Binding, so that it can be more flexible and support different formats - XAML, HTML, plain text, DOCX.
As it comes to your scenario, I have tested it and it seemed to work fine. I may be doing something differently, so I am sending you my testing demo. Look through it and if it doesn't help you address the problem, feel free to get back to us with a project of yours.

Regards,
Iva
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Kirk Quinbar
Top achievements
Rank 1
answered on 21 Dec 2010, 11:38 PM
I got your sample to work which is encouraging, but we have the opposite need where instead of the text being over a certain length we want to validate whether the textbox is empty. this seemed to present more problems than i could figure out.

first off, the htmldataprovider always outputs a minimal amount of text even when the editor is completely empty, so i cant check for length=0 on the viewmodel. It seems odd to me that if the editor is empty that the htmldataprovider outputs anything, but i assume you want to follow html standards and output at least the base <html></html>? is that what you were trying to accomplish? it seems to me more people would want it to output nothing as opposed to an empty html document (meaning just the opening and closing tags)

second, i tried adding an additional textdataprovider bound the same way, because not only do i need the html output when the editor has text in it but i wanted to validate 0 length text at the same time and the only thing that outputs no text when the editor is empty is the textdataprovider. but doing both of these bindings at the same time seems to cause weirdness with the editor in what gets displayed. i think the two databindings are fighting for control of the editor which might be the problem.

any thoughts on being able to get html output when the editor has text in it, but also be able to validate using standard silverlight validation when the editor has no text? a working sample as you did before would be much appreciated if this is possible because i couldnt get this scenerio to work.

Kirk
0
Iva Toteva
Telerik team
answered on 23 Dec 2010, 12:40 PM
Hello Kirk Quinbar,

Indeed, you cannot have both providers bound to RadRichTextBox. We have decided to export empty documents via HtmlFormatProvider as valid HTML files that will allow them to be directly saved.
We will consider the introduction of a property (IsDocumentEmpty for example) that will aid your scenario, but a change in the way that the provider works is highly improbable. The goal of HtmlFormatProvider after all is to output HTML, while an empty document is not a valid one according to the specifications.
Until we review your scenario, your only option is to validate the length of the document in another way.
If you have any other questions, do not hesitate to contact us again.

All the best,
Iva
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
RichTextBox
Asked by
Kirk Quinbar
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Kirk Quinbar
Top achievements
Rank 1
Share this question
or