CheckBox
From Section 6.4.6 of the book
This example implements a shopping list in which you can click several
CheckBoxes. If you click on the button, the selected items are
listed on the page.
CheckBox.aspx
<%@ Page Language="C#" %>
<html>
<head>
<script Language="C#" Runat="server">
void ButtonClicked(object sender, EventArgs e) {
label.Text = "You bought: ";
if (apples.Checked) label.Text += "Apples ";
if (pears.Checked) label.Text += "Pears ";
if (bananas.Checked) label.Text += "Bananas ";
}
</script>
</head>
<body>
<form Runat="server">
<asp:CheckBox ID="apples" Text="Apples" Runat="server" /><br>
<asp:CheckBox ID="pears" Text="Pears" Runat="server" /><br>
<asp:CheckBox ID="bananas" Text="Bananas" Runat="server" /><br>
<asp:Button Text="Buy" OnClick="ButtonClicked" Runat="server" />
<br><br>
<asp:Label ID="label" Runat="server" />
</form>
</body>
</html>
|
Try it
http://dotnet.jku.at/book/samples/6/CheckBox.aspx
|