سؤال

I'm using the ASP.NET Membership provider and using the Password Recovery control to reset the user password if they forget it. On the whole it all works fine, but with one catch when it comes to validation.

I have expanded the PasswordRecovery control out to use the template feature to customise the appearance, which is all fine. I have set the user lookup error handler using:

OnUserLookupError="PasswordRecovery1_UserLookupError"

in the opening tag and if I load up the page, type in some junk name and click submit this fires as expected, in all browsers. The snippet of VB code makes an error div visible and sets some text.

However, if upon loading the page for the first time I type a duff name into the username box and hit the enter key to submit the form, in Internet Explorer (version 8), the UserLookupError event fails to trigger. It triggers just fine in Chrome or Firefox, just not in IE. I know it's not a focus issue on the form, as I can see the form is being submitted.

If I click the submit button first, then following that hit the enter key it does fire, it's just that first time it doesn't, and only in IE.

Also to add that if I set breakpoints in the VB code to check to see if the page is being submitted, I can see the Page_Load event fire when I hit the enter key, but not the sub PasswordRecovery1_UserLookupError.

Has anyone else seen this? It looks like a bug in IE (no really???), but I need to nail it down.

Any help would be welcome.

هل كانت مفيدة؟

المحلول

OK, after some more digging and testing this is actually only a default button issue. I'm not sure what's happening when the enter key is being pressed (only in IE) after text has been entered in the box, as it is reloading the page but not submitting it. There is no other control or function on the page which would navigate back to or refresh this page.

Despite the submit button appearing to be the default button it actually isn't. The key here therefore is setting the defaultbutton property of the webform. That however, when the button is inside a PasswordRecovery control is another issue.

EDIT:

Here's the fix. Set the default button at the page load stage.

Me.Form.DefaultButton = PasswordRecovery1.UserNameTemplateContainer.FindControl("SubmitButton").UniqueID
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top