如何检查具有相同文本框值的两个不同的Web表单

时间:2013-01-11 12:42:05

标签: asp.net validation jquery-validate webforms

的aspx TextBox1.Text World.aspx TextBox1.Text

我希望页面Hello.aspx和World.aspx具有相同的验证值

请帮助我任何人有关于此的想法

1 个答案:

答案 0 :(得分:1)

您需要使用Cookie或数据库或其他内容将值保存在第一页上。 然后检索第二页中的值并比较验证函数或事件中的值。

using(SqlConnection cn = new SqlConnection(connStr))
    {


    using(SqlCommand cmd = new SqlCommand())
    {
        cmd.Connection = cn;

        string sql = string.Format(@"select email from customers where customer_id = '{0}'", customer_id);

        cmd.CommandType = CommandType.Text;

        //try and catch block would go here

        cmd.CommandText = sql;

        cn.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        string email = rdr[0].ToString();
        cn.Close();
    }
    }