当我想在ASP.NET中使用带有AJAX的OnKeyUp
事件时,我必须这样做:
@using(Ajax.BeginForm("Action", "Controller", new AjaxOptions{... UpdateTargetId = "target"}) {
<div id = "target"></div>
@Html.TextBox ("TextField","", new {@OnKeyUp = "TriggerFunction()"}
<input type="submit" id = "button" style = "display:none"/>
}
然后在JQuery中
function TriggerFunction(){
$("#button").trigger("click")
}
虽然这有效,但我很好奇ASP.NET MVC有没有内置功能来做到这一点?我的意思是根据BeginForm
或OnKeyUp
等不同事件触发OnChanged
方法?