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

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!";
}
}
 
M

Michael Nemtsev

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>
 
K

K Viltersten

Ah, that's the way i do it already. I was hoping not to
use JavaScript, actually. Perhaps, i should abandon
that idea.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top