[Asp. net2.0] programming with the webform component checkboxlist in ASP. NET
Source: Internet
Author: User
Yes, the following sources are executed: ProgramCode(Check. aspx:
Check. aspx source code is as follows:
<% @ Page Language = "C #" %>
<HTML>
<Head>
<Title> checkboxlist component demo </title>
<SCRIPT runat = "server">
Protected void button_click (Object sender, eventargs E)
{
// The text in the check box and the position of the check box in the component
Switch (cboalign. selectedindex)
{
Case 0:
Chklist. textalign = textalign. Left;
Break;
Case 1:
Chklist. textalign = textalign. Right;
Break;
}
// Check box layout in the component
Switch (cborepeatlayout. selectedindex)
{
Case 0:
Chklist. repeatlayout = repeatlayout. Table;
Break;
Case 1:
Chklist. repeatlayout = repeatlayout. flow;
Break;
}
// Check box arrangement direction in the component
Switch (cborepeatdirection. selectedindex)
{
Case 0:
Chklist. repeatdirection = repeatdirection. vertical;
Break;
Case 1:
Chklist. repeatdirection = repeatdirection. horizontal;
Break;
}
// The number of lines in each check box in the component
Try
{
Int Cols = int. parse (txtrepeatcols. Text );
Chklist. repeatcolumns = Cols;
}
Catch (exception)
{
}
Lblresult. Text = "";
For (INT I = 0; I <chklist. Items. Count; I ++)
{
If (chklist. items [I]. Selected)
{
Lblresult. Text + = chklist. items [I]. Text + "<br> ";
}
}
}
</SCRIPT>
</Head>
<Body>
<Form runat = "server">
<H1 align = center> checkboxlist component demo
<Table>
<Tr>
<TD> text placement in the component: </TD>
<TD>
<Asp: dropdownlist id = cboalign runat = "server">
<Asp: listitem> left </ASP: listitem>
<Asp: listitem> right </ASP: listitem>
</ASP: dropdownlist>
</TD>
</Tr>
<Tr>
<TD> layout of entries in the component: </TD>
<TD>
<Asp: dropdownlist id = cborepeatlayout runat = "server">
<Asp: listitem> table Type </ASP: listitem>
<Asp: listitem> compact </ASP: listitem>
</ASP: dropdownlist>
</TD>
</Tr>
<Tr>
<TD> arrangement of entries in the component: </TD>
<TD>
<Asp: dropdownlist id = cborepeatdirection runat = "server">
<Asp: listitem> horizontal direction </ASP: listitem>
<Asp: listitem> vertical </ASP: listitem>
</ASP: dropdownlist>
</TD>
</Tr>
<Tr>
<TD> Number of lines in each entry in the component: </TD>
<TD> <asp: textbox id = "txtrepeatcols" runat = "server"/> </TD>
</Tr>
</Table>
<Br>
Select the computer language type you want to learn:
<Br>
<Asp: checkboxlist id = "chklist" repeatdirection = horizontal runat = "server">
<Asp: listitem> visual c ++. Net </ASP: listitem>
<Asp: listitem> Visual C # </ASP: listitem>
<Asp: listitem> VB. NET </ASP: listitem>
<Asp: listitem> JScript. Net </ASP: listitem>
<Asp: listitem> Visual J # </ASP: listitem>
</ASP: checkboxlist>
<Br>
<Asp: button text = "Submit" runat = "server" onclick = "button_click"/>
<H1> <font color = Red> the computer language type you select is: </font>
<Asp: Label id = lblresult runat = "server"/>
</Form>
</Body>
</Html>
6. Summary:
In fact, the checkboxlist component is also a server component. This article describes some of the main attributes and methods of the checkboxlist component. NET page, in fact, for another important component, checkbox, they have many similarities, after understanding the usage of the checkboxlist component, you can also master the usage of the checkbox component.
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