---
title: "Show an error on a label box for invalid username or password"  
description: "Show an error on a label box for invalid username or password"  
author: "Royce Roy"  
published: 2013-12-16  
updated: 2013-12-16  
canonical: https://www.mindstick.com/forum/1776/show-an-error-on-a-label-box-for-invalid-username-or-password  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Show an error on a label box for invalid username or password

Hi Guys

This is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii). How to write the code [label](https://www.mindstick.com/articles/12835/print-label-tracking-how-do-these-features-make-auspost-woocommerce-plugin-better) box. I am selecting [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) from two different [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) for each table it ll [redirect](https://www.mindstick.com/forum/2005/radio-button-redirect) to two different pages. protected void Button1_Click(object sender, EventArgs e) { [var](https://www.mindstick.com/forum/33920/what-is-different-var-and-dynamic-types-in-c-sharp) qry = (from [test](https://yourviews.mindstick.com/story/1427/explosive-facts-about-trinity-test-world-s-first-nuclear-bomb) in je.employee where test.emp_email.Equals(TxtUserName.Text) &[amp](https://www.mindstick.com/forum/156207/what-is-amp); test.emp_pass.Equals(TxtPassword.Text) [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) 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");            }         }}
```

## Replies

### Reply by Pravesh Singh

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!";    }
```


---

Original Source: https://www.mindstick.com/forum/1776/show-an-error-on-a-label-box-for-invalid-username-or-password

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
