In the previous example, break down-> checkboxlist and checkbox

Source: Internet
Author: User
<% @ Page Language = "vb" Debug = "true" %>
<Html> <Script language = "VB" runat = "server">
'Processing the submit button event
Sub btn_click (sender as object, e as commandeventargs)
Dim s, temp as string, I, j as integer
For I = 0 to chkfond. items. count-1 'loop from 0 to the maximum index-1 of the chkfond set.
If chkfond. items (I). selected then 'Add the selected course item to temp
Temp = temp & chkfond. items (I). text &"\"
J + = 1
End if
Next
If j> 0 then s = "<br> the course is:" & temp &". "'Here, pay attention to the subsequent values. s & = indicates that this value is still stored in the variable S.
Lbl. text = s & "<br> submit:" & e. commandname & "-" & e. commandargument 'the content displayed on the label
End sub
'Process the chkdirection selection change event and change the chkfond arrangement direction.
Sub chk_checkedchanged (sender as object, e as eventargs)
If chkdirection. checked = true then', if the checked attribute of chkdirection is selected,
Chkfond. repeatdirection = repeatdirection. horizontal then horizontally
Else' otherwise
Chkfond. repeatdirection = repeatdirection. vertical 'is arranged vertically.
End if
End sub
</Script>
<Body>
<Form runat = "server">
Select your course selection <br/>
<Asp: CheckBoxList ID = "chkfond" runat = "server">
<Asp: ListItem> literature </asp: ListItem>
<Asp: ListItem> music </asp: ListItem>
<Asp: ListItem> politics </asp: ListItem>
<Asp: ListItem> history </asp: ListItem>
<Asp: ListItem> philosophy </asp: ListItem>
<Asp: ListItem> sports </asp: ListItem>
</Asp: CheckBoxList>
<! -- Specify the direction of chkfond -->
<Asp: CheckBox ID = "chkdirection" runat = "server" AutoPostBack = "true" Checked = "false" Text = "horizontal arrangement" OnCheckedChanged = "chk_checkedchanged"/>
<! -- Submit and Clear button -->
<Asp: Button ID = "btn" runat = "server" Text = "Submit" oncommand = "btn_click" CommandName = "time" CommandArgument = "1900-08-20"/>
<Asp: Label ID = "lbl" runat = "server"/>
</Form>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.