Set Focus on a Textbox – MVC3

You could provide an additional class to the containing div:

<div class="editor-field focus">
    @Html.EditorFor(model => model.Amount)
    @Html.ValidationMessageFor(model => model.Amount)
</div> 

and then you could use a jQuery class selector:

$(function() {
    $('.focus :input').focus();
});

This being said you seem to have multiple Amount texboxes in a table and obviously only one can have the focus at a time. So assuming you want this to be the first, you could do this:

$('.focus :input:first').focus();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)