Do You Help Users By Selecting A Default Field

Updated by Tom Bui [SSW] 1 year ago. See history

123

Help your users by setting the default field when your MVC Website loads.

By selecting a default field for your users when a page loads you can improve the usability of your website by reducing the amount of steps needed to perform a task. Here is a way to do this with MVC 3 and Razor:

1. Add a div with a class around the field you want to set focus on

<div class="focus">
@Html.EditorFor(model => model.FirstName)
@Html.ValidationMessageFor(model => model.FirstName)
</div>
  1. Then use jQuery to select the class and set focus:
$(function() {
$('.focus :input').focus();
});
acknowledgements
related rules