ASP.NET回车键和形式没有提交的JavaScript [英] ASP.NET enter key and form submit with no javascript

查看:85
本文介绍了ASP.NET回车键和形式没有提交的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想要当用户presses回车键提交表单。它工作正常在Firefox,但不是在IE浏览器。它基本上是同样的问题,因为这,但我不能使用任何JavaScript:
<一href=\"http://stackoverflow.com/questions/270494/enter-button-does-not-submit-form-ie-only-asp-net\">http://stackoverflow.com/questions/270494/enter-button-does-not-submit-form-ie-only-asp-net

I have a form that I want to submit when the user presses the enter key. It works fine in Firefox, but not in IE. It is basically the same issue as this, except that I am not allowed to use any JavaScript: http://stackoverflow.com/questions/270494/enter-button-does-not-submit-form-ie-only-asp-net

不幸的是,它看起来像ASP.NET使用JavaScript来处理按钮回发。有没有解决这个问题的方式,不依赖于JavaScript?

Unfortunately it looks like ASP.NET uses JavaScript to process the button postback. Is there a way around this issue that doesn't rely on JavaScript?

推荐答案

对此的解决办法是什么在你的链接后页面的底部列出。 IE浏览器需要有一个额外的表单字段出于某种原因,这个工作。我已经在很多项目中使用此,连带周围的错误。只需添加以下内容。

The fix for this is what was listed in the bottom of the page of your linked post. IE needs to have an additional form field for some reason for this to work. I have used this in many projects, and it gets around the bug. Just add the following.

<!-- Fix for IE bug submit on pressing "Enter") -->
<div style="display:none">
            <input type="text" name="hiddenText"/>
</div>

这篇关于ASP.NET回车键和形式没有提交的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆