做了个按钮,<asp:Button ID="del" runat="server" OnClick="del_Click" Text="删除教师" />
后台代码 public void del_Click(object sender, EventArgs e)
{
Response.Write("<script>if(confirm('确定删除吗?')==false){history.back();}</script>"); string sql = "delete from tbuser where userid='" + tb_teaid.Text + "'";
using (SqlConnection con = new SqlConnection(connstr))
{
当我第一次点按钮时,页面刷新了,但没跳确认框,第二次才跳了确认框,很奇怪
后台代码 public void del_Click(object sender, EventArgs e)
{
Response.Write("<script>if(confirm('确定删除吗?')==false){history.back();}</script>"); string sql = "delete from tbuser where userid='" + tb_teaid.Text + "'";
using (SqlConnection con = new SqlConnection(connstr))
{
当我第一次点按钮时,页面刷新了,但没跳确认框,第二次才跳了确认框,很奇怪
return false;
}
这句话 不应该写在cs页面里 写在前台
OnClientClick="return confirm('确认删除')"
Button1.Attributes.Add("onclick", "return confirm('确定要删除么?')");
或 ClientScript.RegisterStartupScript(this.GetType(), "PleaseCheck", "if(confirm('确定删除吗'))document.getElementById('hf').value='1';else
document.getElementById('hf').value='0;",true);
if(hf.value.Equals("1"))
{ }
但就楼主的代码来看。。
好像我看不出有什么明显的问题