سؤال

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