Asp.net mvc MVC Html.begin捕获按键事件

Asp.net mvc MVC Html.begin捕获按键事件,asp.net-mvc,razor,html-helper,Asp.net Mvc,Razor,Html Helper,我有一个MVC应用程序,我正在使用Html.BeginForm制作表单。页面上有几个表单,每个表单代表一行选项卡中的一个选项卡。我需要检测其中一个选项卡上按下的“回车”键。有人知道怎么做吗 代码示例- <div> @using (Html.BeginForm("MyAction", "MyController", FormMethod.Post, new { id = "MyForm1" })) { <div id="divId"> </div>

我有一个MVC应用程序,我正在使用Html.BeginForm制作表单。页面上有几个表单,每个表单代表一行选项卡中的一个选项卡。我需要检测其中一个选项卡上按下的“回车”键。有人知道怎么做吗

代码示例-

<div>
@using (Html.BeginForm("MyAction", "MyController", FormMethod.Post, new { id = "MyForm1" }))
{
    <div id="divId">
    </div>
}
</div>

@使用(Html.BeginForm(“MyAction”、“MyController”、FormMethod.Post、new{id=“MyForm1”}))
{
}
谢谢

@using (Html.BeginForm("Create", "ApplicationSchedule", FormMethod.Post, 
        new { onkeydown = "return event.keyCode!=13" }))

您可以使用htmlAttributes对象参数将事件侦听器添加到表单中,就像我使用代码中的
new{onkeydown=“return event.keyCode!=13”}
部分所做的那样。在我的例子中,当使用onkeydown侦听器在表单中按下enter键时,我忽略了它。使用您自己的代码(如
onkeydown=“yourJavascriptFunction()”
)可以轻松地替换此功能,以实现在表单中按enter键时需要实现的任何功能。有关Html.BeginForm()接受的参数的详细信息,请参见

通常最容易获取。您打算如何在不接受键盘输入的元素上捕获enter键?Mystere Man,我只想检测是否已按下“enter”键。将特定javascript的运行与该操作绑定在一起