Prasad Sam

Prasad Sam

  • NA
  • 5
  • 1.1k

Visual Studio 2010 Form Checkbox value C#

Oct 28 2014 10:24 AM
I created a form page, I have several check boxes and and Text boxes on the form page.  Checkboxes named like  Group1,Group2,Group3,Group4, and Group5.  textbox named as RErrors.  I just want to show the value in textbox if check box is checked.  (If 5 check box are checked then value will be 5, 3 checked means 3, show in text box.)
 
I tried to put the below code but nothing happens.
 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

int sum = 0;

if (Group1.Checked == true) sum += 1;

if (Group2.Checked == true) sum += 1;

if (Group3.Checked == true) sum += 1;

if (Group4.Checked == true) sum += 1;

if (Group5.Checked == true) sum += 1;

//return sum RErrors

}

}


Answers (4)