Postback issue with ASP .NET 2.0

Discussion in 'ASP .Net' started by James Thomas, Jun 22, 2006.

  1. James Thomas

    James Thomas Guest

    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);
    }
    }
     
    James Thomas, Jun 22, 2006
    #1
    1. Advertising

  2. 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 (, 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.
     
    Walter Wang [MSFT], Jun 23, 2006
    #2
    1. Advertising

  3. James Thomas

    James Thomas Guest

    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

    Walter Wang [MSFT] wrote:

    > 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 (, 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.
     
    James Thomas, Jun 23, 2006
    #3
  4. 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 (, 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.
     
    Walter Wang [MSFT], Jun 24, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Gutknecht \(RS\)
    Replies:
    1
    Views:
    494
    Ravikanth[MVP]
    Aug 1, 2003
  2. Psych971
    Replies:
    5
    Views:
    4,636
    bruce barker
    Dec 17, 2004
  3. =?Utf-8?B?Q2hhZA==?=

    Postback not being set to True on first postback

    =?Utf-8?B?Q2hhZA==?=, Apr 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    512
    =?Utf-8?B?Q2hhZA==?=
    Apr 4, 2005
  4. =?Utf-8?B?VG9tIEFuZGVyc29u?=

    ASP.Net Multiple PostBack Issue

    =?Utf-8?B?VG9tIEFuZGVyc29u?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    12,453
    Ealavan
    May 10, 2010
  5. Replies:
    0
    Views:
    4,156
Loading...

Share This Page