add multiple validators to a control

Jun 26, 2009 at 6:13 PM

Is this possible?  I'd like to add a RangeValidator and a RequiredValidator to a text box, if this is possible can you provide an example of how to do so?  Thanks.

Jun 26, 2009 at 7:20 PM

Yes of course.

You can use the ValidationGroup.



<font size="2">




 ValidationGroup group = new ValidationGroup(
                new ValidationItem(new AlnumValidator(false), txtUsername, TextBox.TextProperty),
                new ValidationItem(new NotEmptyValidator(), txtUsername, TextBox.TextProperty)


<font size="2">

Or simply use the Silverlight Forms Toolkit.



 formLogin.AddTextBox("username", "Username:", new IValidator[] { new NotEmptyValidator(), new AlnumValidator(false) });

Jun 26, 2009 at 7:46 PM

I tried to add that code to my control but it doesn't recognize ValidationGroup.  I looked online and it looks like this is in the System.Web.UI.WebControls namespace which does not appear to be available from the Add Reference menu in VS.  What am I overlooking here?  Thanks.

Jun 26, 2009 at 10:28 PM

The ValidationGroup class exists in the exsportance.Silverlight.Validate namespace. Here is the class file in source control:

Jun 30, 2009 at 8:23 PM

fascinating.  somehow i downloaded the controls from, and then found this and didn't notice that this was  Very confusing, I wouldn't have guessed there would be two projects with such similar intent, but thanks for responding to my questions without treating me like a complete idiot :)