Is it possible to set the focus on the following code on a page load without the use of JavaScript?
<div class="col-md-10">
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
</div>
Is it possible to set the focus on the following code on a page load without the use of JavaScript?
<div class="col-md-10">
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
</div>
Your can use the
autofocus
attribute. Refer documentationThe equivalent for
EditorFor
(using MVC-5.1+ only) is obtained with the following syntax:You can add id to your div and pass this id int the end of the url of your page: