' ASPX_DropDown_RadioButton_and_CheckBox_List_Controls_plus_ListBox.aspx.vb.txt
' Writen by Dan Garlen dan.g@kgsystems.com 2/22/04
'
' Add one each of the following Controls (leaving their default names) to a WebForm
' DropDownList
' RadioButtonList
' CheckBoxList
' ListBox
'
' Add Lable named "lblSelected"
'
Private arrWeekDays() As String = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not (Page.IsPostBack) Then
Dim i As Integer
For i = 0 To 6
Dim li As New ListItem
li.Value = i.ToString
li.Text = arrWeekDays(i)
DropDownList1.Items.Add(li)
ListBox1.Items.Add(li)
RadioButtonList1.Items.Add(li)
CheckBoxList1.Items.Add(li)
Next
End If
End Sub
' ===============================================================================================
Private Sub AnyListChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles _
DropDownList1.SelectedIndexChanged, _
ListBox1.SelectedIndexChanged, _
RadioButtonList1.SelectedIndexChanged, _
CheckBoxList1.SelectedIndexChanged
Dim lc As ListControl = CType(sender, Control)
'Dim strListControl As String = lc.GetType.ToString ' returns type of control
Dim strListControl As String = lc.ClientID ' returns name of control
Dim strTitle As String = "Sender = " + strListControl + "
"
Dim strBody As String
Dim li As ListItem
For Each li In lc.Items
If li.Selected Then
strBody &= "