【问题标题】:help in events of checkbox_checkedchange and button click在复选框选中更改和按钮单击事件中提供帮助
【发布时间】:2011-02-10 18:42:14
【问题描述】:

基本上我有几个复选框。如果选中复选框 1,我会将字符串分配给变量。所以我会让每个复选框都有自己的字符串,这些字符串将保存到一个文本文件中。

只有当一个按钮被点击时,这些字符串才会被保存到文本文件中。

我这样做了:

    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
    string masterbuild1 = "Exec_Build_starting_mail";
}

    protected void Button1_Click(object sender, EventArgs e)
        {

            // create a writer and open the file
            TextWriter tw = new StreamWriter("C:/Documents and 
Settings/Cha57061/Desktop/New Folder/C#/new/build.txt");

            // should i have a if statement like:
if CheckBox1_CheckedChanged = true
            {
            tw.Write(masterbuild1);
            }
            // close the stream
            tw.Close();

我想我需要在按钮单击时添加 if else 语句.. 提前致谢

【问题讨论】:

    标签: c# asp.net checkbox buttonclick


    【解决方案1】:

    您为什么不检查checkbox 在按钮单击中的状态并分配字符串值。 如果您不能这样做,那么在Check_Changed 事件中将其分配给视图状态,然后在按钮中单击检查值并继续。 (该事件触发检查和取消检查..不确定你在找什么!)

    【讨论】:

    • 谢谢。我想通了。在 buttonclick 事件上我做了一个 if (checkbox1.checked) {do something};效果很好
    猜你喜欢
    • 2011-03-29
    • 2011-10-25
    • 2019-08-23
    • 2011-04-21
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多