如何禁用浏览器后面的弹出窗口和前进按钮

时间:2015-09-16 08:21:21

标签: javascript jquery .net

我只需在操作完成时使用popUp在Aspx页面上插入操作

enter image description here

问题是,当我通过浏览器后退和前进按钮浏览此页面时...此弹出窗口再次显示在加载

这是我的插入代码

 protected void insert()
    {
        try
        {
            if (txtusername1.Text=="")
            { 
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "User Name can't Blank" + "');", true);
                txtusername1.BackColor = System.Drawing.Color.LightPink;
            }
            else if (txtpwd.Text == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Password can't Blank" + "');", true);
                txtpwd.BackColor = System.Drawing.Color.LightPink;
            }
            else
            {
                if (txtid.Text.Trim().ToString() == "")
                {

                    SqlCommand comd1 = new SqlCommand();
                    comd1.Connection=con;

                    con.Open();
                    comd1.CommandText = "INSERT INTO Professormaster(UserName,Password,Name,contactNo,Email,remark,AdminID,isSelected) " +
                        "VALUES(@UserName,@Password,@Name,@contactNo,@Email,@remark,@AdminID,@isSelected)";
                    comd1.Parameters.AddWithValue("@UserName", txtusername1.Text.Trim());
                    comd1.Parameters.AddWithValue("@Password", txtpwd.Text.Trim());
                    comd1.Parameters.AddWithValue("@Name", String.Empty);
                    comd1.Parameters.AddWithValue("@contactNo", Convert.ToInt32(txtContactNo.Text.Trim()));
                    comd1.Parameters.AddWithValue("@Email", txtxEmailID.Text.Trim());
                    comd1.Parameters.AddWithValue("@remark", txtRemark.Text.Trim());
                    comd1.Parameters.AddWithValue("@AdminID", Convert.ToInt32(Session["AdminID"]));
                    comd1.Parameters.AddWithValue("@isSelected", true);

                    comd1.ExecuteNonQuery();
                    con.Close();

                    ClearItem();
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Insert Successfully!" + "');", true);
                    BindData();
                    ClearItem();
                }
                else
                {
                    SqlCommand comd1 = null;
                         con.Open();
                    comd1.ExecuteNonQuery();
                    con.Close();
                    ClearItem();

                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Update Successfully!" + "');", true);
                    BindData();
                    ClearItem();
                }

            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

如何避免PopUp出现在浏览器后退和前进按钮上?

0 个答案:

没有答案