点击一个按钮,然后想让他弹出一个选择对话框。如果确认就将数据保存到数据库,如果取消,就返回当前页面。代码如下:
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("<script>if(confirm('注意!您将要提交最后的数据,请确认后再提交!'));</script>");
if (confirm("确定") == true)
{
Response.Write("<script>alert('提交成功!');");
}
else
{
Response.Redirect("ZHtjqrx.aspx");
} }
中间代码意思是这个意思,但是可能这么写不正确。运行时也显示confirm不存在。请问中间这段代码应该怎么写呢?
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("<script>if(confirm('注意!您将要提交最后的数据,请确认后再提交!'));</script>");
if (confirm("确定") == true)
{
Response.Write("<script>alert('提交成功!');");
}
else
{
Response.Redirect("ZHtjqrx.aspx");
} }
中间代码意思是这个意思,但是可能这么写不正确。运行时也显示confirm不存在。请问中间这段代码应该怎么写呢?
" if( window.confirm('添加成功(*^__^*),您是否想继续添加?'))"
+ " { window.location.href='NewsEdit.aspx' } "
+ " else { window.location.href='NewsList.aspx' } "
, true);
最后是用 ajax 解决的
你这段代码可以换一下, 在页面的pageload事件里面 给你那个按钮
attributes.add("onclick","if(!confirm('确定提交吗?'){return false;})");
你的cs代码一样使用的
你保存数据的代码 写在你按钮的click事件里面啊!
string str1 = "update ZH_total set zb1='" + a1 + "'where year='" + b + "'";
string str2 = "update ZH_total set zb2='" + a2 + "'where year='" + b + "'";
SqlCommand cmd = new SqlCommand(string.Format(str), con);我想把上边2个sql语句整合在一起,请问怎么整合呢。zb1,和zb2用小括号括起来么?还是中间用AND?