Postback issue with ASP .NET 2.0

J

James Thomas

I have an issue with the login process on my site since the upgrade to
ASP .NET 2.0 (from 1.1).

I have the standard textbox and button for logging and my own custom
login process. I'd like to continue using this as it works fine
(usually) and meets my needs exactly.

Anyway, When a user logs in successfully, everything is fine. When an
invalid user name and password is entered, I inform the user of this
using a javascript alert(). This also works fine. However, on the VERY
NEXT click .

Alert is a simple function that sends a javascript alert using
ClientScript.RegisterStartupScript() to display an alert on the client.
I am fairly certain that the problem isn't with the login code as the
alert is being sent correctly to the client.

The only way to get this working is to cause a redirect to happen,
redirecting the page to itself.

Any ideas?

Thanks,

James

Here's my code:

protected void btnLogin_Click(object sender, EventArgs e)
{
Succeed.Login login = new X.Login(txtLogin.Text, txtPassword.Text);

string redirect = "";

switch (login.go())
{
case X.Login.Status.Admin:
redirect = "xxx.aspx";
break;
case X.Login.Status.Expired:
Alert("Login expired. Please call xxx-xxx-xxxx to renew.");
return;
case X.Login.Status.GroupOwner:
redirect = "xxxx.aspx";
break;
case X.Login.Status.Invalid: // ** HERE **
Alert("Invalid login or password. Please try again.");
return;
default: // Success!
redirect = "xxx_Main.aspx";
break;
}

if (redirect.Length > 0)
{

if (State.Check("SSO") == false)
{
string script = "SetCloseParent(true); PopupSize('" + redirect +
"','xxx'," // URL
+ "'800px','600px');";
Script(script);
}
else
UI.Goto(redirect);
}
}
 
W

Walter Wang [MSFT]

Hi James,

Thank you for your post.

Based on my understanding, the question is:
1) You are registering some startup javascript to display a alert dialog
but it only shows up upon next postback.
Please correct me if I've misunderstood anything.

Since you didn't posted the function "Alert", so I wrote my "Alert"
function as follows:

private void Alert(string p)
{
ClientScript.RegisterStartupScript(GetType(), "alert",
"javascript:alert('" + p + "');", true);
}

And that function works correctly using a simple button's click event.

Is it possible it's related to the "login.go()" call? What's it doing?
Could you please post the code or describe it briefly?

If possible, could you please send me a repro project? Thanks.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

James Thomas

No actually - the problem is that the alert is display just fine on the
same postback. However, once it is sent, the client no longer responds
to any POST events - any button I click appears to do nothing.

The problem actually was in my login.go() method, though not directly.
I am using the new Theme structure of ASP .NET 2.0, and I load the
theme name (and therefore theme folder) from the database in the
Page_PreInit() method. The problem was that I was setting the LoginId
to -1 in the session and then trying to load the theme from the
database with a LoginId of -1 (which there wasn't) - this was causing
an error and my default error page was getting redirected to, which was
loading the theme from the database and causing another redirect - and
therefore gave the appearance of no response.

A simple removal of the Login Id being set to -1 when not needed
resolved my problem.

Thanks!

James
 
W

Walter Wang [MSFT]

Hi James,

Thank you for your reply and the detailed additional feedback on how you
were successful in resolving this issue. This information has been added to
Microsoft's database. Your solution will benefit many other users, and we
really value having you as a Microsoft customer.

If you have any other questions or concerns, please do not hesitate to
contact us. It is always our pleasure to be of assistance.

Have a nice day!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top