checkbox_checkedchange 和按钮单击事件的帮助
基本上我有几个复选框。如果选中复选框 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 语句..提前致谢
basically i have a few check boxes. if checkbox 1 is checked, i will assign a string to a variable. so i will have each check boxes having their own strings which will be saved into a text file.
only when a button is clicked, then these strings will be saved into text file.
i did this:
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();
i think i need to add upon button click an if else statement.. thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不在按钮单击中检查
复选框
的状态并分配字符串值。如果您无法做到这一点,则在
Check_Changed
事件中将其分配给视图状态,然后在按钮中单击检查值并继续操作。(该事件会因检查和取消检查而触发......不知道您在寻找什么!)
Why don't you check the state of the
checkbox
in button click and assign the string values.If you cannot do that then in the
Check_Changed
event assign it to viewstate and then in the button click check for the value and proceed further.(The event fires for checking and unchecking.. not sure what are you looking for !)