How do you add a key down event with this text box?

@Html.TextBox("txtbx1", "", new {...} )
有帮助吗?

解决方案

You could do something like the following:

@Html.TextBox("txtbx1", "", new { onkeydown="MyFunction();" } )

其他提示

Try it like this.

Call:

@Html.TextBoxFor(model => model.BoardSizeX, new { @onkeydown = "return Foo(event, $(this).val());"})

Function:

 function foo(event, currentValue) {
       console.log(event);
       console.log(currentValue);

       return true; 
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top