The MultipleRequiredControlsValidator evaluates two or more data entry controls
to evaluate if they are blank or have data.
It supports a mixture of data entry controls. All DES TextBoxes, native TextBox,
ListBox, DropDownList, CheckBoxList, RadioButtonList, CheckBox, and RadioButton.
With lists, it can evaluate either the current textual value or the selected index.
Use the Mode property to determine how many must be assigned. If you select
Mode=Range, fill in Minimum and Maximum.
Specify the first two textboxes to evaluate with the ControlIDToEvaluate
and SecondControlIDToEvaluate properties. Use the ControlsToEvaluate
property to define a list of additional controls (textual and list-type).
The objects added to ControlsToEvaluate are:
- PeterBlum.DES.Web.WebControls.RequiredTextControl - Use with TextBox controls.
Assign the ID of the control to its ControlIDToEvaluate property. Define
an alternative to what is considered unassigned with the UnassignedValues
and UnassignedCaseInsensitive properties.
- PeterBlum.DES.Web.WebControls.RequiredListControl - Use with ListBox and DropDownList
controls. Assign the ID of the control to its ControlIDToEvaluate property.
Define the index considered unassigned with the UnassignedIndex property.
- PeterBlum.DES.Web.WebControls.RequiredCheckStateControl - Use with CheckBox and
RadioButton controls. Assign the ID of the control to its ControlIDToEvaluate
property. By default, it assumes an unchecked control is unassigned and checked
is assigned. If you want to switch that, set the CheckedIsAssigned property
to false.
The validators all refer to these textboxes. Start by clicking Submit to see the initial errors.
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
if (PeterBlum.DES.Globals.WebFormDirector.IsValid)
{
}
}
</script>
The validators all refer to these textboxes. Start by clicking Submit to see the initial errors.<br/><br/>
<asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" ></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server" ></asp:TextBox>
<des:TextBox ID="TextBox5" runat="server" ></des:TextBox><br/>
<des:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"></des:Button>
<br/>
<h2>Mode=All</h2>
<des:MultipleRequiredControlsValidator ID="MultipleRequiredControlsValidator1" runat="server"
Mode="All"
ErrorMessage="All must be assigned"
ControlIDToEvaluate="TextBox1"
SecondControlIDToEvaluate="TextBox2">
<ControlsToEvaluate>
<des:RequiredTextControl ControlIDToEvaluate="TextBox3" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox4" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox5" />
</ControlsToEvaluate>
</des:MultipleRequiredControlsValidator>
<br/>
<br/>
<h2>Mode=OnlyOne</h2>
<des:MultipleRequiredControlsValidator ID="MultipleRequiredControlsValidator2"
runat="server" ErrorMessage="Only one can be assigned"
Mode="OnlyOne">
<ControlsToEvaluate>
<des:RequiredTextControl ControlIDToEvaluate="TextBox1" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox2" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox3" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox4" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox5" />
</ControlsToEvaluate>
</des:MultipleRequiredControlsValidator>
<br/>
<br/>
<h2>Mode=AllOrNone</h2>
<des:MultipleRequiredControlsValidator ID="MultipleRequiredControlsValidator3"
runat="server" ErrorMessage="Assign them all"
Mode="AllOrNone"
ControlIDToEvaluate="TextBox1"
SecondControlIDToEvaluate="TextBox2">
<ControlsToEvaluate>
<des:RequiredTextControl ControlIDToEvaluate="TextBox3" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox4" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox5" />
</ControlsToEvaluate>
</des:MultipleRequiredControlsValidator>
<br/>
<br/>
<h2>Mode=AtLeastOne</h2>
<des:MultipleRequiredControlsValidator ID="MultipleRequiredControlsValidator4"
runat="server" ErrorMessage="At least one must be assigned"
Mode="AtLeastOne">
<ControlsToEvaluate>
<des:RequiredTextControl ControlIDToEvaluate="TextBox1" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox2" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox3" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox4" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox5" />
</ControlsToEvaluate>
</des:MultipleRequiredControlsValidator>
<br/>
<br/>
<h2>Mode=Range, Minimum=3</h2>
<des:MultipleRequiredControlsValidator ID="MultipleRequiredControlsValidator5"
runat="server" ErrorMessage="Three or more must be assigned"
Mode="Range" Minimum="3">
<ControlsToEvaluate>
<des:RequiredTextControl ControlIDToEvaluate="TextBox1" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox2" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox3" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox4" />
<des:RequiredTextControl ControlIDToEvaluate="TextBox5" />
</ControlsToEvaluate>
</des:MultipleRequiredControlsValidator>
<br/>