try
        {
            if (this.Txtname.Text==""||this.TxtPwd.Text=="")
            {
                Response.Write("<script>alert('有未填写的资料请检查')</script>");            }
                else if(!this.TxtPwd.Text.Equals(this.TxtNPwd.Text))
            {
                Response.Write("<script>alert('密码和确认密码不相同 请检查')</script>");
            }
            else if (string.Compare(Session["CheckCode"].ToString(), this.TxtImages.Text, true) != 0)
            {
                Response.Write("<script>alert('验证码不正确')</script>");
                return;
            }
          
            else
            {                GetSql g = new GetSql();
                SqlConnection conn = g.GetMySql();
                conn.Open();
                SqlCommand com = new SqlCommand("Stor_User", conn);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.Add("@UserName", SqlDbType.VarChar).Value = this.Txtname.Text;
                com.Parameters.Add("@NickName", SqlDbType.NVarChar).Value = this.TxtNname.Text;
                com.Parameters.Add("@UserPwd", SqlDbType.VarChar).Value = this.TxtPwd.Text;
                com.Parameters.Add("@nUserPwd", SqlDbType.VarChar).Value = this.TxtNPwd.Text;
                com.Parameters.Add("@Age", SqlDbType.VarChar).Value = this.DropDownList1.SelectedItem.Text;
                com.ExecuteNonQuery();               
                SqlDataReader re = com.ExecuteReader();
                while (re.Read())
                {
                    Response.Write("<script>alert('注册成功 将跳转到登陆页面')</script>");
                    Response.Redirect("Login.aspx");
                }
                conn.Close();            }
            this.Txtname.Text = string.Empty;
            this.TxtNname.Text = string.Empty;
            this.TxtNPwd.Text = string.Empty;
            this.TxtPwd.Text = string.Empty;
            this.TxtImages.Text = string.Empty;
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }问题来了
当全部填写正确的时候 可以插入!问题是没有弹出提示!并且插入到数据库中是2条重复的记录 怎么回事?

解决方案 »

  1.   

    为什么还没有解决。。
    问题是插入成功后
     while (re.Read()) 
                    { 
                        Response.Write(" <script>alert('注册成功 将跳转到登陆页面') </script>"); 
                        Response.Redirect("Login.aspx"); 
                    } 
    提示没有弹出
      

  2.   

    Response.Write(" <script>alert('注册成功 将跳转到登陆页面') </script>"); 
                        Response.Redirect("Login.aspx"); ========
    你Redirect了,脚本当然不起作用了
      

  3.   

    Response.Write(" <script>alert('注册成功 将跳转到登陆页面');window.location='login.aspx
    ' </script>"); 
      

  4.   

    window.location='login.aspx 
    '.........
    后台可以写前台的代码阿?
    额 我刚培训毕业
    看来好多要学阿 哎
      

  5.   

    后台只有Response.Write这一种跳转方式?
      

  6.   

    Response.Write(" <script>alert('注册成功 将跳转到登陆页面') </script>"); 
                        Response.Redirect("Login.aspx"); ======== 
    你Redirect了,脚本当然不起作用了 
      

  7.   

    Response.Write(" <script>alert('注册成功 将跳转到登陆页面');window.location='login.aspx 
    ' </script>"); 正解
      

  8.   

    最好别用Response.Write用ClientScript.RegisterStartupScript:
    ClientScript.RegisterStartupScript(typeof(Page),""," <script>alert('注册成功 将跳转到登陆页面');location.href='login.aspx;'</script>");
      

  9.   

    你这里执行了两次吧
    com.ExecuteNonQuery(); 
    SqlDataReader re = com.ExecuteReader(); 
      

  10.   

    不要用Response.Write输出脚本,用Page.ClientScript.RegisterStartupScript方法来做比较好