ASP.NET 4 密码恢复验证仅在 IE 中失败
我正在使用 ASP.NET 会员资格提供程序,并使用密码恢复控件在用户忘记密码时重置用户密码。总的来说,一切都很好,但在验证方面有一个问题。
我已经扩展了PasswordRecovery控件以使用模板功能来自定义外观,这一切都很好。我已经使用以下方式设置了用户查找错误处理程序:
OnUserLookupError="PasswordRecovery1_UserLookupError"
在开始标记中,如果我加载页面,请输入一些垃圾名称,然后单击“提交”,这会在所有浏览器中按预期触发。 VB 代码片段使错误 div 可见并设置一些文本。
但是,如果在第一次加载页面时,我在用户名框中输入一个无意义的名称并按 Enter 键提交表单,则在 Internet Explorer(版本 8)中,UserLookupError
事件无法执行扳机。它在 Chrome 或 Firefox 中触发得很好,但在 IE 中却不行。我知道这不是表单的焦点问题,因为我可以看到表单正在提交。
如果我先单击“提交”按钮,然后按 Enter 键,它会触发,只是第一次不会触发,而且仅在 IE 中。
另外要补充的是,如果我在 VB 代码中设置断点来检查页面是否正在提交,那么当我按下 Enter 键时,我可以看到 Page_Load
事件触发,但看不到子 PasswordRecovery1_UserLookupError
。
还有其他人看过这个吗?它看起来像是 IE 中的一个错误(不是真的???),但我需要确定它。
欢迎任何帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,经过更多的挖掘和测试,这实际上只是一个默认按钮问题。我不确定在框中输入文本后按下回车键(仅在 IE 中)时会发生什么,因为它正在重新加载页面但不提交页面。页面上没有其他控件或功能可以导航回或刷新此页面。
尽管提交按钮看起来是默认按钮,但实际上不是。因此,这里的关键是设置网络表单的
defaultbutton
属性。然而,当按钮位于PasswordRecovery
控件内时,则是另一个问题。编辑:
这是修复方法。在页面加载阶段设置默认按钮。
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 aPasswordRecovery
control is another issue.EDIT:
Here's the fix. Set the default button at the page load stage.