5
在我WebForm
我想總價格變化時,用戶檢入一個產品,但是我有這個問題,我的代碼,的CheckedChanged事件不會觸發
的CheckedChanged
事件在不觸發,當我檢查CheckBox
只有當我點擊Button
(用作清除按鈕)時纔會觸發,並且我沒有在按鈕事件中包含該代碼!
這裏是我的代碼:
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;
}
}
非常感謝! –