Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i hava login form within that have adiv that contains login panel in that i need to clear both textbox and label value when user gives wrong credentials. This will look cool for the user who accidentally gives wrong details... Any Help Will be appreciated...
Posted

1 solution

In the button click event, if the user authentication fails, set the text propert of your textbox and label to empty string.
Something like:
C#
protected void Button1_Click(object sender, EventArgs e)
{
    //if user authentication failed
    TextBox1.Text = "";
    Label1.Text = "";
    //lblErrorMessage = "Invalid Username or Password!";
}


What is the label for?

You should also have a label which notifies the user about the authentication failure (I have added that as a comment in the code).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900