Home > DeveloperSection > Forums > Show an error on a label box for invalid username or password
Royce Roy
Royce Roy

Total Post:134

Points:938
Posted on    December-16-2013 12:28 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 972  View(s)
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");

            }

         }

}



Pravesh Singh

Total Post:411

Points:2881
Posted on    December-16-2013 12:48 AM

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!";

    }


Don't want to miss updates? Please click the below button!

Follow MindStick