回车键不提交表单(即只)ASP.NET [英] Enter button does not submit form (IE ONLY) ASP.NET

查看:283
本文介绍了回车键不提交表单(即只)ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框和一个按钮的形式。 IE浏览器时,输入是pressed(在FF,歌剧,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)"

任何意见?

编辑: 上的 = HTTP://www.$c$cproject.com/> $ C $的CProject 概述了Dillie在说什么,它完美的作品

This page on CodeProject outlines what Dillie was saying, and it works perfectly.

推荐答案

我在过去做的另一件事是包装形式区面板和设置DefaultButton属性提交按钮就搞定了。这有效地映射,只要你有清晰出现在面板区域表单元素回车键提交。

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.

这篇关于回车键不提交表单(即只)ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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