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条重复的记录 怎么回事?
{
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条重复的记录 怎么回事?
问题是插入成功后
while (re.Read())
{
Response.Write(" <script>alert('注册成功 将跳转到登陆页面') </script>");
Response.Redirect("Login.aspx");
}
提示没有弹出
Response.Redirect("Login.aspx"); ========
你Redirect了,脚本当然不起作用了
' </script>");
'.........
后台可以写前台的代码阿?
额 我刚培训毕业
看来好多要学阿 哎
Response.Redirect("Login.aspx"); ========
你Redirect了,脚本当然不起作用了
' </script>"); 正解
ClientScript.RegisterStartupScript(typeof(Page),""," <script>alert('注册成功 将跳转到登陆页面');location.href='login.aspx;'</script>");
com.ExecuteNonQuery();
SqlDataReader re = com.ExecuteReader();