MVC3输入按钮输入所触发按钮 [英] MVC3 input button triggered by Enter button
本文介绍了MVC3输入按钮输入所触发按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ASP.NET MVC 3 C#.NET Web应用程序,我想的输入的按钮来触发我的窗体上的特定保存按钮。我会怎么做呢?
I have an ASP.NET MVC 3 C#.NET web application and I want the Enter button to trigger a particular Save button on my form. How would I do that?
推荐答案
我会做的是利用JavaScript的这一个。办理安其preSS
甚至在格式即可。像这样:
What I would do is utilize JavaScript for this one. Handle the onkeypress
even of the form. Like so:
<form onkeypress="yourKeyPressFunction(event)">
...
</form>
那么你的 yourKey pressFunction()
会是这个样子:
function yourKeyPressFunction(e)
{
if (e.keyCode == 13)
{
// submit or do what you'd like when you hit enter
}
// ... so on and so forth
}
这篇关于MVC3输入按钮输入所触发按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文