Use radiobuttonlist with VB

Radiobuttonlist with VB 

The RadioButton control is used to give a set of similar  options.  User can choose one radio button in a  particular group. If you want to place more than one group  in the same form, Then you can use  different container controls like a GroupBox1,GroupBox2...etc control.



Example of  button list with VB language:

Radiobuttonlist  in vb
Radiobuttonlist  in vb

<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
   <script language="VB" runat="server">
      Sub Button1_Click(Source As Object, e As EventArgs)
         If RadioButtonList1.SelectedIndex > - 1 Then
            Label1.Text = "You selected: " & _
                          RadioButtonList1.SelectedItem.Text
         End If
      End Sub

      Sub chkLayout_CheckedChanged(sender As Object, e As EventArgs)       
         If chkLayout.Checked = True Then
            RadioButtonList1.RepeatLayout = RepeatLayout.Table
         Else
            RadioButtonList1.RepeatLayout = RepeatLayout.Flow
         End If
      End Sub

      Sub chkDirection_CheckedChanged(sender As Object, e As EventArgs)       
         If chkDirection.Checked = True Then
            RadioButtonList1.RepeatDirection = RepeatDirection.Horizontal
         Else
            RadioButtonList1.RepeatDirection = RepeatDirection.Vertical
         End If
      End Sub
   </script>
</head>
<body>
   <form runat="server">
      <h3>RadioButtonList Example</h3>
      <asp:RadioButtonList id=RadioButtonList1 runat="server">
         <asp:ListItem>Item 1</asp:ListItem>
         <asp:ListItem>Item 2</asp:ListItem>
         <asp:ListItem>Item 3</asp:ListItem>
         <asp:ListItem>Item 4</asp:ListItem>
         <asp:ListItem>Item 5</asp:ListItem>
         <asp:ListItem>Item 6</asp:ListItem>
      </asp:RadioButtonList>
      <p>
      <asp:CheckBox id="chkLayout"
           OnCheckedChanged="chkLayout_CheckedChanged"
           Text="Display Table Layout"
           Checked=true AutoPostBack="true"
           runat="server" />
      <br>
      <asp:CheckBox id="chkDirection"
           OnCheckedChanged="chkDirection_CheckedChanged"
           Text="Display Horizontally"
           AutoPostBack="true"
           runat="server" />
      <p>
      <asp:Button id="Button1"
           Text="Submit"
           OnClick="Button1_Click"
           runat="server"/>
      <p>
      <asp:Label id="Label1"
           Font-Name="Verdana"
           Font-Size="8pt"
           runat="server"/>
   </form>
</body>

Comments

Popular posts from this blog