Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta charset="utf-8" /> <title></title> <style> h3 { text-align: center; } </style> </head> <body> <form id="form1" runat="server"> <div> <h3>Вычисление суммы отмеченных цифр</h3> <asp:CheckBox ID="CheckBox1" runat="server" Text="1" TextAlign="Right" /> <br /> <asp:CheckBox ID="CheckBox2" runat="server" Text="2" TextAlign="Right" /> <br /> <asp:CheckBox ID="CheckBox3" runat="server" Text="3" TextAlign="Right" /> <br /> <asp:CheckBox ID="CheckBox4" runat="server" Text="4" TextAlign="Right" /> <br /> <asp:CheckBox ID="CheckBox5" runat="server" Text="5" TextAlign="Right" /> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Вычислить" OnClick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="Очистить" OnClick="Button2_Click" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> </div> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta charset="utf-8" /> <title></title> <style> h3 { text-align: center; } </style> </head> <body> <form id="form1" runat="server"> <div> <h3>Вычисление суммы отмеченных цифр</h3> <asp:CheckBox ID="CheckBox1" runat="server" Text="1" TextAlign="Right" /> <br /> <asp:CheckBox ID="CheckBox2" runat="server" Text="2" TextAlign="Right" /> <br /> <asp:CheckBox ID="CheckBox3" runat="server" Text="3" TextAlign="Right" /> <br /> <asp:CheckBox ID="CheckBox4" runat="server" Text="4" TextAlign="Right" /> <br /> <asp:CheckBox ID="CheckBox5" runat="server" Text="5" TextAlign="Right" /> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Вычислить" OnClick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="Очистить" OnClick="Button2_Click" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> </div> </form> </body> </html>
Default.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { int result = 0; if(CheckBox1.Checked) { result += int.Parse(CheckBox1.Text); } if(CheckBox2.Checked) { result += int.Parse(CheckBox2.Text); } if(CheckBox3.Checked) { result += int.Parse(CheckBox3.Text); } if(CheckBox4.Checked) { result += int.Parse(CheckBox4.Text); } if(CheckBox5.Checked) { result += int.Parse(CheckBox5.Text); } Label1.Text = result.ToString(); } protected void Button2_Click(object sender, EventArgs e) { Label1.Text = string.Empty; CheckBox1.Checked = false; CheckBox2.Checked = false; CheckBox3.Checked = false; CheckBox4.Checked = false; CheckBox5.Checked = false; } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { int result = 0; if(CheckBox1.Checked) { result += int.Parse(CheckBox1.Text); } if(CheckBox2.Checked) { result += int.Parse(CheckBox2.Text); } if(CheckBox3.Checked) { result += int.Parse(CheckBox3.Text); } if(CheckBox4.Checked) { result += int.Parse(CheckBox4.Text); } if(CheckBox5.Checked) { result += int.Parse(CheckBox5.Text); } Label1.Text = result.ToString(); } protected void Button2_Click(object sender, EventArgs e) { Label1.Text = string.Empty; CheckBox1.Checked = false; CheckBox2.Checked = false; CheckBox3.Checked = false; CheckBox4.Checked = false; CheckBox5.Checked = false; } }