Why can't i see the text update on my asp:Button?

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

I'm using the following method for authorization. I wonder if
it's at all possible to make it show the text on the second line
WHILE validating and then, if the login has failed, show the
red message. When i run the code, i don't get to see it...

protected void SubmitData(object sender, EventArgs e) {
LogInInformation.Text = "Validating the credentials...";
if (CommunicationLayer.IsActiveMember(
UserName.Text, Password.Text)) {
FormsAuthentication.RedirectFromLoginPage(
UserName.Text, false);
LogInInformation.Text = "";
}
else {
LogInInformation.ForeColor = Color.Red;
LogInInformation.Text = "Invalid credentials!";
}
}
 
Hello K,

To implement what you want you need to do it differently
1) use javascript to show additional text when it's shown or
2) wrap validation in asynchronious method, to call it separately after you
set the message

The reason why current message is not shown (actually it's shown but it's
not rendered) is that message and all validation happens in the same page
lifecycle.
You need to set message first, complete page lifecycle to have it rendered.
And then process another event for validation.

I'd recommend to go with JS behaviour with is called fron OnClientClick of
the button, and which just shows the hidden div with your text

---
WBR,
Michae Nemtsev [Microsoft MVP] :: blog: http://msmvps.org/blogs/laflour
:: http://twitter.com/laflour

"Tis nothing good or bad, but thinking makes it so" (c) W.Shakespeare


KV> if (CommunicationLayer.IsActiveMember(
KV> UserName.Text, Password.Text)) {
KV> FormsAuthentication.RedirectFromLoginPage(
KV> UserName.Text, false);
KV> LogInInformation.Text = "";
KV> }
KV> else {
KV> LogInInformation.ForeColor = Color.Red;
KV> LogInInformation.Text = "Invalid credentials!";
KV>
 
Ah, that's the way i do it already. I was hoping not to
use JavaScript, actually. Perhaps, i should abandon
that idea.

Thanks!
 
Back
Top