Enter button does not submit form (IE ONLY) ASP.NET(输入按钮不提交表单(仅限 IE)ASP.NET)
问题描述
我有一个带有文本框和按钮的表单.IE 是唯一在按下 Enter 时不会提交表单的浏览器(适用于 FF、Opera、Safari、Chrome 等).我发现这个 javascript 函数试图哄骗 IE 行为;但无济于事:
I have a form with a textbox and a button. IE is the only browser that will not submit the form when Enter is pressed (works in FF, Opera, Safari, Chrome, etc.). I found this javascript function to try to coax IE into behaving; but no avail:
function checkEnter(e){
var characterCode
if (e && e.which) {
e = e
characterCode = e.which
} else {
e = event
characterCode = e.keyCode
}
if (characterCode == 13) {
document.forms[0].submit()
return false
} else {
return true
}
}
实施:
searchbox.Attributes("OnKeyUp") = "checkEnter(event)"
有什么建议吗?
此页面在CodeProject 概括了 Dillie 所说的内容,而且效果很好.
This page on CodeProject outlines what Dillie was saying, and it works perfectly.
推荐答案
我过去做的另一件事是将表单区域包装在 Panel 中,并将 DefaultButton 属性设置为您拥有的提交按钮.只要您在面板区域中有一个表单元素处于焦点位置,这就会有效地将 enter 键映射到提交.
The other thing I have done in the past is wrap the form area in a Panel and set the DefaultButton attribute to the submit button you have. This effectively maps the enter key to the submission as long as you have a form element in focus in the panel area.
这篇关于输入按钮不提交表单(仅限 IE)ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:输入按钮不提交表单(仅限 IE)ASP.NET


- 在 C# 中异步处理项目队列 2022-01-01
- 使用 rss + c# 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01