Sign in to follow this  

[web] ASP.Net button events not firing...

This topic is 3662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is totally biting me in the butt. Yesterday my site was running just fine on localhost. It's currently running off of localhost, and uses Forms Authentication to validate users. In my web.config, I have the default page set up to the "UserProfile.aspx" page, and the login page set to "Login.aspx", both of which are valid webpages. On the login page there is two text boxes and a button (as well as a few other things). The user is supposed to put in their username and password, and click the button. The code behind the button trims the text fields, and checks them against the database to see if they are indeed valid. Here's the problem though - the button click event isn't even being fired! I'm not getting any errors or exceptions - just no event being fired. I tried restarting IIS as well as rebooting the machine this is all running off of, but that didn't help. I just can't figure it out - the site was running just fine yesterday, and now it isn't. Anyone? Help?!

Share this post


Link to post
Share on other sites
I've done some googling, but I still have no idea what the problem is. Some users with the .Net framework 1.1 were having problems, but this is running .Net 2.0.

I am really thinking that it is somehow the forms authentication that is screwing up. When I enter a good username/password and click the "Login" button, the event doesn't fire but the URL string does change from something like:

http://localhost:8080/Forum/Login.aspx

To:

http://localhost:8080/Forum/Login.aspx?ReturnUrl=%2fForum%2fUserProfile.aspx

To me, that looks fine. It's failing the login (the "Login" button has the postback URL set to "~/UserProfile.aspx"), and the event for the button isn't getting fired.

Aaarrg! This is driving me nuts!

Share this post


Link to post
Share on other sites
Well, I'll be darned. I removed the PostBackURL button on the Login button, and now it seems to work. The login button event is now firing. Odd.

Share this post


Link to post
Share on other sites
If you specify a postback url there, the server will generate a new instance of the page specified in the url, and your event ceases to exist even if it would ultimately refer to the same page that the request came from.

By contrast, not specifying the postback url will cause the server to response by retrieve the current page object from the view state; thus, your event handler will live on.

Share this post


Link to post
Share on other sites
I believe the PostBackUrl is mainly to allow for cross-page post-back. Even if you specified the current url for the PostBackUrl, it is still being treated as a cross-page post back, basically what Nik02 is describing.

Share this post


Link to post
Share on other sites

This topic is 3662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this