You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You write the following code fragment.
<asp:ListBox SelectionMode="Multiple" ID="ListBox1" runat="server"> </asp:ListBox>
<asp:ListBox ID="ListBox2" runat="server"> </asp:ListBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
You need to ensure that when you click the Button1 control, a selected list of items move from the ListBox1 control to the ListBox2 control.
Which code segment should you use?
A.
For Each li As ListItem In ListBox1.Items
If li.Selected Then
ListBox2.Items.Add(li)
ListBox1.Items.Remove(li)
End If
Next
B.
For Each li As ListItem In ListBox1.Items
If li.Selected Then
li.Selected = False
ListBox2.Items.Add(li)
ListBox1.Items.Remove(li)
End If
Next
C.
For Each li As ListItem In ListBox1.Items
If li.Selected Then
li.Selected = False
ListBox2.Items.Add(li)
End If
Next
D.
For Each li As ListItem In ListBox2.Items
If ListBox1.Items.Contains(li) Then
ListBox1.Items.Remove(li)
End If
Next
E.
For Each li As ListItem In ListBox1.Items
If li.Selected Then
ListBox1.Items.Remove(li)
End If
Next
F.
For Each li As ListItem In ListBox1.Items
If ListBox2.Items.Contains(li) Then
ListBox1.Items.Remove(li)
End If
Next