SHOW AN ERROR ON A LABEL BOX FOR INVALID USERNAME OR PASSWORD

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
 1218  View(s)
Ratings:
Rate this:

Hi Guys

This is my code. How to write the code label box. I am selecting data from two different table for each table it ll redirect to two different pages. protected void Button1_Click(object sender, EventArgs e) { var qry = (from test in je.employee where test.emp_email.Equals(TxtUserName.Text) & test.emp_pass.Equals(TxtPassword.Text) select test).FirstOrDefault();

        if (null != qry)

        {

            Response.Redirect("EmployeeHome.aspx");

        }          

        else

        {

            var qry2 = (from test1 in je.employer

                        where test1.c_mail.Equals(TxtUserName.Text) &

                              test1.c_pass.Equals(TxtPassword.Text)

                        select test1).FirstOrDefault();

            if (null != qry2)

            {

                Response.Redirect("EmployerHome.aspx");

            }

         }

}

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Show an error on a label box for invalid username or password

    Hi Royce,


    Try this:

    var qry = (from test in  je.employee

                      where test.emp_email.Equals(TxtUserName.Text) & test.emp_pass.Equals(TxtPassword.Text)

                       select test).FirstOrDefault();

       var qry2 = (from test1 in je.employer

                        where test1.c_mail.Equals(TxtUserName.Text) & test1.c_pass.Equals(TxtPassword.Text)

                        select test1).FirstOrDefault();

        if (null!=qry)

        {

            Response.Redirect("EmployeeHome.aspx");

        }

        else if(null != qry2)

        {

             Response.Redirect("EmployerHome.aspx");         

        }

        else

        {

            Label1.Text = "Incorrect username or password!";

        }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!