用户成功注册并将他重定向到登录页面时,如何显示消息框 [英] How can I show messagebox when user register successfully and redirect him to Login page

查看:116
本文介绍了用户成功注册并将他重定向到登录页面时,如何显示消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的signUp按钮事件是

My signUp button event is

protected void signup_Click(object sender, EventArgs e)
    {
        string con = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
        SqlConnection conn = new SqlConnection(con);
        conn.Open();
       if (selectques.SelectedItem.Text == "Write your own question?")
        {
            SqlCommand cmd = new SqlCommand("insert into registration values('" + username.Text + "','" + passwrd.Text + "','" + emailadd.Text + "','" + alterquestion.Text + "','" + securityanswer.Text + "')", conn);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
        else
        {
            SqlCommand cmd = new SqlCommand("insert into registration values('" + username.Text + "','" + passwrd.Text + "','" + emailadd.Text + "','" + selectques.Text + "','" + securityanswer.Text + "')", conn);
            cmd.ExecuteNonQuery();
            conn.Close();
        }



成功注册后,如何显示Successful Registered 消息并将其重定向到登录页面.我想通过弹出窗口或消息框显示消息.



After registering successfully how can I show a message of Successful Registered and redirect him to login page. I want to show the message through Popup window or messagebox.

推荐答案

同意Mark.防止SQL注入攻击.检查这些

SQL注入
SQL注入攻击以及有关如何防止它们的一些提示 [ SQL注入攻击 [ SQL注入知识 [ SQL注入和跨站点脚本 [
Agree with Mark. Prevent the SQL injection attacks. Check these

SQL injection
SQL Injection Attacks and Some Tips on How to Prevent Them[^]
SQL injection attacks[^]
SQL Injection Knowhow[^]
SQL Injection and Cross-Site Scripting[^]

For redirection & messagebox, see this
ClientScript.RegisterStartupScript(Page.GetType(), "Message", "alert('Successful Registered');window.location='login.aspx';", true);


如果页面中使用了AJAX,


If AJAX used in page,

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Message", "alert('Successful Registered');window.location='login.aspx';", true);


首先,绝不接受未经验证的用户输入,并在SQL语句中使用它.曾经.您正在对SQL注入攻击敞开大门.您的应用程序非常不安全.您应该使用存储过程,或者至少使用参数化查询.

如果要将用户发送到另一个页面,请使用Response.Redirect或Server.Transfer.要首先显示一条消息,您可以使用Page.RegisterClientScriptBlock插入JavaScript.所有这些方法都有很好的文档记录.
First and formost NEVER accept unvalidated user input and use it in a SQL statement. EVER. You are opening yourself for SQL injection attacks. Your application is extremely unsecure. You should be using stored procedures or at the very least parameterized queries.

If you want to send the user to another page use Response.Redirect or Server.Transfer. To display a message first you can insert JavaScript with Page.RegisterClientScriptBlock. All of these methods are well documented.


Alert.show(成功注销");

试试这个..........
Alert.show("Successfully Logout");

Try This..........


这篇关于用户成功注册并将他重定向到登录页面时,如何显示消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆