---
title: "How to change Failure text for two different possibilities?"  
description: "How to change Failure text for two different possibilities?"  
author: "Anonymous User"  
published: 2014-12-08  
updated: 2014-12-09  
canonical: https://www.mindstick.com/forum/12771/how-to-change-failure-text-for-two-different-possibilities  
category: "asp.net"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How to change Failure text for two different possibilities?

I have [ASP](https://www.mindstick.com/articles/751/introduction-to-asp-dot-net-mvc) [Login Control](https://www.mindstick.com/articles/627/login-control-in-asp-dot-net) in my [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) and a

```
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
```

What I want to do is that when I perform [authentication](https://www.mindstick.com/blog/177/authentication-and-authorization-in-asp-dot-net) in

```
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e){    DAL = new DataAccessLayer();    conObj = DAL.openConnection();    string query = "SELECT * FROM tblUser WHERE UEmail = '"+Login1.UserName+"'";     SqlDataReader SQLDR = DAL.ExecuteQueryReturnValue(query);     if (SQLDR.Read())    {        if (SQLDR["UPassword"].ToString() == Login1.Password.ToString())        {             Session["userName"] = SQLDR["UEmail"].ToString();            e.Authenticated = true;        }        else {            // Change the 'FailureText' to "password is incorrect"            e.Authenticated = false;        }     }    else    {        // Here I want to change the 'FailureText' to "User does not exists"        e.Authenticated = false;    }   }
```

set the [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) of FailureText to

"Incorrect [Password](https://www.mindstick.com/blog/118/retriving-user-password-by-using-stored-procedure-in-asp-dot-net)"

Or set to

"[User](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) does not exist"

for both possibilities.

## Replies

### Reply by Jayden Bell

Try this:

```
if (SQLDR.HasRow()){    if(SQLDR.Read())    {        if(SQLDR["UEmail"].ToString() == Login1.UserName.ToString())        {            if(SQLDR["UPassword"].ToString() == Login1.Password.ToString())            {               
Session["userName"] = SQLDR["UEmail"].ToString();               
e.Authenticated = true;            }            else            {               
FailureText.Text = "password is incorrect";               
e.Authenticated = false;            }        }    }}else{    FailureText.Text =
"User does not exists";    e.Authenticated =
false;}
```

### Reply by Anonymous User

You can declare a string variable within the method and set it accordingly:

```
protected void Login1_Authenticate(object sender,AuthenticateEventArgs e){    DAL = new DataAccessLayer();    conObj =DAL.openConnection();    string query ="SELECT * FROM tblUser WHERE UEmail ='"+Login1.UserName+"'";    string failureText=string.empty;     SqlDataReader SQLDR = DAL.ExecuteQueryReturnValue(query);     if (SQLDR.Read())    {        if(SQLDR["UPassword"].ToString() == Login1.Password.ToString())        {            
Session["userName"] = SQLDR["UEmail"].ToString();           
e.Authenticated = true;        }        else {            // Change the 'FailureText' to "password is incorrect"           
failureText="password is incorrect";           
e.Authenticated = false;        }     }    else    {        // Here I want to change the 'FailureText' to "User does not exists"       
failureText="User does not exists";       
e.Authenticated = false;    }    
if(!e.Authenticated)    {        // Use failureText where you need it       
FailureText.Text=string.Format("<h1>{0}</h1>",
failureText);    }    else    {       
FailureText.Text=string.empty;    }   }
```


---

Original Source: https://www.mindstick.com/forum/12771/how-to-change-failure-text-for-two-different-possibilities

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
