<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
if (PeterBlum.DES.Globals.WebFormDirector.IsValid)
{
}
}
</script>
<h2>Example 1</h2>
Using a Multiselection ListBox with <span class="PropertyName">Minimum</span>=2.
Select a minimum of 2<br/><br/>
<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:ListBox>
<des:CountSelectionsValidator ID="CountSelectionsValidator1" runat="server" ControlIDToEvaluate="ListBox1"
ErrorMessage="Select at least {MINIMUM} items" Minimum="2">
</des:CountSelectionsValidator>
<br/><br/>
<h2>Example 2</h2>
Using a Multiselection ListBox. This example uses the <span class="PropertyName">NotCondition</span>
to invert the range from <span class="PropertyName">Minimum</span>=2 and
<span class="PropertyName">Maximum</span>=3,
so only 1 and 4 selections are permitted.<br/>
Select only one or all.<br/>
<br/><br/>
<asp:ListBox ID="ListBox2" runat="server" SelectionMode="Multiple">
<asp:ListItem>Blue</asp:ListItem>
<asp:ListItem>Green</asp:ListItem>
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Yellow</asp:ListItem>
</asp:ListBox>
<des:CountSelectionsValidator ID="CountSelectionsValidator2" runat="server" ControlIDToEvaluate="ListBox2"
ErrorMessage="Select one or all" Minimum="2" Maximum="3" NotCondition="true">
</des:CountSelectionsValidator>
<br/><br/>
<h2>Example 3</h2>
Using CheckBoxList with <span class="PropertyName">Maximum</span>=2. Select no more than 2 items.<br/><br/>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:CheckBoxList>
<des:CountSelectionsValidator ID="CountSelectionsValidator3" runat="server" ControlIDToEvaluate="CheckBoxList1"
ErrorMessage="Select no more than {MAXIMUM} items" Maximum="2">
</des:CountSelectionsValidator>
<br/><br/>
<des:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"></des:Button>