Message not displayed

  • Thread starter Thread starter Colin Basterfield
  • Start date Start date
C

Colin Basterfield

Hi,

I have a Login screen which has a Label on it, and if the login is
successful it clears the message and moves to the main screen, but if the
login fails due to a bad password or username the text property of the label
is assigned "bad Username or Password", however although stepping thro the
code it does hit that line it doesn't display the message.

Prolly something silly but I don't what it is yet so...

TIA
Colin B
 
Yes of course:

private void btnLogin_Click(object sender, System.EventArgs e)
{
bool pwdVerified = false;
try
{
pwdVerified = VerifyPassword(txtUserName.Text, txtPassword.Text);
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
return;
}
if (pwdVerified == true)
{
lblMessage.Text = "";
// Creates an authentication ticket and attaches it to the cookie's collection of the outgoing
// response. It does not perform a redirect.
FormsAuthentication.SetAuthCookie(txtUserName.Text, true);

// Set the UserID in the session variable

Session["UserID"] = txtUserName.Text;

// Move to the Selection screen

Response.Redirect("Selection.aspx");

}

else

{

lblMessage.Text = "Invalid username or password";

}

}

Nothing much to it than that really.

Any ideas?
Colin B
 
Is the lable visible and enabled?

Yes of course:

private void btnLogin_Click(object sender, System.EventArgs e)
{
bool pwdVerified = false;
try
{
pwdVerified = VerifyPassword(txtUserName.Text, txtPassword.Text);
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
return;
}
if (pwdVerified == true)
{
lblMessage.Text = "";
// Creates an authentication ticket and attaches it to the cookie's
collection of the outgoing
// response. It does not perform a redirect.
FormsAuthentication.SetAuthCookie(txtUserName.Text, true);
// Set the UserID in the session variable
Session["UserID"] = txtUserName.Text;
// Move to the Selection screen
Response.Redirect("Selection.aspx");
}
else
{
lblMessage.Text = "Invalid username or password";
}
}
Nothing much to it than that really.

Any ideas?
Colin B
 
Now I'm feeling stooopid, Visible was set False...I always assume it's
complicated...

I'll get me coat. :-)

thanks,
Colin
Sharon said:
Is the lable visible and enabled?

Yes of course:

private void btnLogin_Click(object sender, System.EventArgs e)
{
bool pwdVerified = false;
try
{
pwdVerified = VerifyPassword(txtUserName.Text, txtPassword.Text);
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
return;
}
if (pwdVerified == true)
{
lblMessage.Text = "";
// Creates an authentication ticket and attaches it to the cookie's
collection of the outgoing
// response. It does not perform a redirect.
FormsAuthentication.SetAuthCookie(txtUserName.Text, true);
// Set the UserID in the session variable
Session["UserID"] = txtUserName.Text;
// Move to the Selection screen
Response.Redirect("Selection.aspx");
}
else
{
lblMessage.Text = "Invalid username or password";
}
}
Nothing much to it than that really.

Any ideas?
Colin B
Sharon said:
Can we see the code?
 
Back
Top