Fill value to asp:ListBox in asp:RadioButtonList selection changed action (VB.net) : ListBox « ASP.net Controls « ASP.NET Tutorial






<%@ Page Language="VB" %>

<script runat="server">
   sub ChangeNames(Sender as Object, e as EventArgs)
      if rlSex.SelectedIndex = 0 then
         'female
         lbNames.Items(0).Text = "A"
         lbNames.Items(1).Text = "B"
         lbNames.Items(2).Text = "C"
         lbNames.Items(3).Text = "D"
      else
         'male
         lbNames.Items(0).Text = "E"
         lbNames.Items(1).Text = "F"
         lbNames.Items(2).Text = "G"
         lbNames.Items(3).Text = "H"
      end if
   end sub
   
   sub DisplayMessage(Sender as Object, e as EventArgs)
      lblMessage.Text = Sender.SelectedItem.Text & _
         " is a wonderful name!"
   end sub

</script>

<html><body>
   <form runat="server">
      <asp:Label id="lblMessage" runat="server"/>
      
      Choose the sex of your baby:
      <asp:RadioButtonList id="rlSex" runat="server"
         OnSelectedIndexChanged="ChangeNames"
         AutoPostBack="true" >
         <asp:ListItem>Female</asp:ListItem>
         <asp:ListItem>Male</asp:ListItem>
      </asp:RadioButtonList>
      
      Possible names:<br>
      <asp:ListBox id="lbNames" runat="server"
         OnSelectedIndexChanged="DisplayMessage"
         AutoPostBack="true" >
         <asp:ListItem></asp:ListItem>
         <asp:ListItem></asp:ListItem>
         <asp:ListItem></asp:ListItem>
         <asp:ListItem></asp:ListItem>
      </asp:ListBox>
   
   </form>
</body></html>








3.16.ListBox
3.16.1.asp:ListBox OnSelectedIndexChanged event and AutoPostBack (VB.net)
3.16.2.Fill value to asp:ListBox in asp:RadioButtonList selection changed action (VB.net)
3.16.3.Bind array data to asp:ListBox (VB.net)
3.16.4.Bind asp:Label with asp:ListBox (VB.net)
3.16.5.Set array value to asp:ListBox DataSource (VB.net)
3.16.6.Selection mode of asp:ListBox (C#)
3.16.7.Selection mode of asp:ListBox (VB)
3.16.8.Using the ListBox control (C#)
3.16.9.Using the ListBox control (VB)
3.16.10.Property tester