Created
April 27, 2016 14:19
-
-
Save rionmonster/42aaf6e13827cb36d1c99b8ac182f881 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CheckBoxChecking.aspx.cs" Inherits="Example.CheckBoxChecking" %> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title></title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<asp:CheckBox ID="CheckBox1" runat="server" /> | |
<asp:CheckBox ID="CheckBox2" runat="server" /> | |
<asp:CheckBox ID="CheckBox3" runat="server" /> | |
<asp:CheckBox ID="CheckBox4" runat="server" /> | |
<asp:CheckBox ID="CheckBox5" runat="server" /> | |
<asp:Button ID="GetCheckedCount" runat="server" OnClick="GetCheckedCount_Click" Text="Get CheckBox Count" /> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
namespace Example | |
{ | |
public partial class CheckBoxChecking : System.Web.UI.Page | |
{ | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
} | |
protected void GetCheckedCount_Click(object sender, EventArgs e) | |
{ | |
var checkedBoxes = Form.Controls.OfType<CheckBox>().Count(c => c.Checked); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment