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}
}
Murugesh PPosted Oct 29, 2014, 10:32 AM
Prasad SamPosted Oct 29, 2014, 2:30 PM
Prasad SamPosted Oct 29, 2014, 9:54 AM
Murugesh PPosted Oct 29, 2014, 8:44 AM
You have written your code in page load where there is no check box checked,If you need to show the number of check box checked(Dynamically) you have to write the code in Javascript for Click event of the Check boxes. If you don't want to display the value dynamically, means on page load itself if you are having some check boxes checked the current code will work. Just assign the value of Sum to textboxid.text property.