In my WebForm I want the total price to change when a user checks a single product, but I have this problem with my code,
The CheckedChanged event CheckedChanged not fire when I check the CheckBox
It is executed only when the Button pressed (used as the "Clear" button), and I did not include this code in the button event!
Here is my code:
public partial class _Default : System.Web.UI.Page { int total = 0; String strtotal; protected void ckb1_CheckedChanged(object sender, EventArgs e) { if (ckb1.Checked) { total = total + 100; strtotal = total.ToString(); lbl2.Text = strtotal; } } protected void ckb2_CheckedChanged(object sender, EventArgs e) { if (ckb2.Checked) { total = total + 80; strtotal = total.ToString(); lbl2.Text = strtotal; } } protected void ckb3_CheckedChanged(object sender, EventArgs e) { if (ckb3.Checked) { total = total + 70; strtotal = total.ToString(); lbl2.Text = strtotal; } } protected void Button3_Click(object sender, EventArgs e) { TextBox1.Text = " "; ckb1.Checked = false; ckb2.Checked = false; ckb3.Checked = false; } }
source share