[web] ASP.Net button events not firing...
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?!
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!
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!
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement