如果在WinForm中解决这个问题,代码可以如下:
DialogResult result = MessageBox.Show("确定要保存吗?","确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
if(result == DialogResult.Cancel)
{
return; //如是选择取消,则返回
}
else{
//如果选择确定,则执行下一步代码
}
不知道WebForm中是不是类似?
DialogResult result = MessageBox.Show("确定要保存吗?","确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
if(result == DialogResult.Cancel)
{
return; //如是选择取消,则返回
}
else{
//如果选择确定,则执行下一步代码
}
不知道WebForm中是不是类似?
{
Button1.CausesValidation=false;
}
什么意思啊!button1.Attributes.Add("onclick", "return confirm('您真的要保存?')");
我的button1怎么会不有Attributes????/
倒是弹出‘你是否保存?’对话框,但验证控件失效(浮点验证)保存出错
如果在button1.click中加入
Button1.CausesValidation=false;则能验证,但不能弹出‘你是否保存?’对话框