4

我有一个 ASP.NET MVC 3 C#.NET Web 应用程序,我希望Enter按钮触发表单上的特定保存按钮。我该怎么做?

4

1 回答 1

1

我要做的是使用 JavaScript 来做这个。处理表格onkeypress的偶数。像这样:

<form onkeypress="yourKeyPressFunction(event)">
...
</form>

然后你yourKeyPressFunction()会看起来像这样:

function yourKeyPressFunction(e)
{
    if (e.keyCode == 13)
    {
        // submit or do what you'd like when you hit enter
    }

    // ... so on and so forth
}
于 2011-12-22T21:40:57.140 回答