<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
if (PeterBlum.DES.Globals.WebFormDirector.IsValid)
{
}
}
protected void MoveAtoB_Click(object sender, EventArgs e)
{
Transfer(ListBoxA, ListBoxB);
}
protected void MoveBtoA_Click(object sender, EventArgs e)
{
Transfer(ListBoxB, ListBoxA);
}
protected void Transfer(ListBox pSourceList, ListBox pDestList)
{
if (pSourceList.SelectedItem != null)
{
ListItem vItem = pSourceList.SelectedItem;
vItem.Selected = false;
pDestList.Items.Add(vItem);
pSourceList.Items.Remove(vItem);
}
}
</script>
ListBox 1 allows a maximum of 4.<br/>
ListBox 2 allows between 2 and 3.<br/><br/>
<asp:ListBox ID="ListBoxA" runat="server" Height="100px" Width="50px">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:ListBox>
<asp:Button ID="MoveAtoB" runat="server" CausesValidation="False" OnClick="MoveAtoB_Click"
Text="Move >>" />
<asp:Button ID="MoveBtoA" runat="server" CausesValidation="False" OnClick="MoveBtoA_Click"
Text="<< Move" />
<asp:ListBox ID="ListBoxB" runat="server" Height="100px" Width="50px">
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:ListBox>
<br/>
Listbox 1 Errors:
<des:ListSizeValidator ID="ListSizeValidator1" runat="server" ControlIDToEvaluate="ListBoxA"
ErrorMessage="Maximum of {MAXIMUM}. You have {COUNT} {COUNT:item:items}." Maximum="4"
Minimum="0">
<ErrorFormatterContainer>
<des:TextErrorFormatter/>
</ErrorFormatterContainer>
</des:ListSizeValidator>
<br/>
ListBox 2 Errors:<des:ListSizeValidator ID="Listsizevalidator2" runat="server" ControlIDToEvaluate="ListBoxB"
ErrorMessage="Between {MINIMUM} and {MAXIMUM}. You have {COUNT} {COUNT:item:items}."
Maximum="3" Minimum="2">
<ErrorFormatterContainer>
<des:TextErrorFormatter/>
</ErrorFormatterContainer>
</des:ListSizeValidator>
<br/>
<des:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"></des:Button>