Featured On ...

asp.net

totalasp.co.uk

fuzzysoftware.com

devdex.com

123aspx.com

dotnetfreaks.com

411asp.net

and more ...

ValidatorEntryOr

Full path

MadWidgets.Validation.ValidatorEntryOr

Declaration

public class ValidatorEntryOr : ValidatorEntryMultipleEntry

Hierarchy

Click on the selected class to view any properties or methods that may be accessible through an instance of this class through inheritance.

ValidatorEntryOr

Overview

The ValidatorEntryOr class is used to represent the logical "OR"ing of the results of two or more validation entries.

In the following example, two ValidatorEntryAnd objects are getting added to a ValidatorEntryOr object, which in turn is getting added to the Validator control.

<script runat="server">
 
void Page_Load(object o, EventArgs ea)
{
Validator v = Validator.Current;
v.Add(new ValidatorEntryRequired(SearchTerm1, "You have not supplied a valid search term in the first search field.", null));
ValidatorEntryOr veo = new ValidatorEntryOr("If you have entered a term in the second search term field, please select a condition. If you have selected a condition but not entered a second search term, please enter the second search term.");
ValidatorEntryAnd vea1 = new ValidatorEntryAnd();
ValidatorEntryAnd vea2 = new ValidatorEntryAnd();
vea1.Add(new ValidatorEntryRequired(SearchTerm2, null, null, true));
vea1.Add(new ValidatorEntryRequired(Condition, null, null, true));
vea2.Add(new ValidatorEntryRequired(SearchTerm2, null, null, false));
vea2.Add(new ValidatorEntryRequired(Condition, null, null, false));
veo.Add(vea1);
veo.Add(vea2);
v.Add(veo);
}
 
void Submit_Clicked(object o, EventArgs ea)
{
if (Page.IsValid)
{
// Do your thang here!
SuccessMessage.Text = "Crikey! You just ran a search!";
}
}
 
</script>

The "OR" portion of the example above is more or less equivalent to the following condition (in Javascript):

var isValid = (SearchTerm2.value == "" && Condition.value == "") || (SearchTerm2.value != "" && Condition.value != "")

Constructors


Constructors

ValidatorEntryOr

public ValidatorEntryOr()

Creates a ValidatorEntryOr with no message.

ValidatorEntryOr

public ValidatorEntryOr(string sMessage)

Creates a ValidatorEntryOr with a message.

ValidatorEntryOr

public ValidatorEntryOr(string sMessage, string sHighlightElement)

Creates a ValidatorEntryOr with a message and a client-side highlight element signature.

© 2002 - 2009 Copyright, Disclaimer and Privacy Statement