Click here to Skip to main content
15,884,064 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi am trying to do autofocus in my view page.I tried the below coding but it focusing the label not Textbox
C#
<div class="contact_form">
    <div class="contact_form1">
    @Html.LabelFor(model => model.Prefix)
    </div>
    @Html.TextBoxFor(model => model.Prefix, new { autofocus = "autofocus",
    @class = "name_form" })
    @Html.ValidationMessageFor(model => model.Prefix)
    </div>

any one please help me to get out of this problem
Posted
Updated 21-Aug-12 19:27pm
v2

1 solution

Check the following SO link:

http://stackoverflow.com/questions/2998247/asp-net-mvc-html-textbox-set-autofocus-property[^]

Else, in case you are using jQuery, you could simply do,

JavaScript
$('.name_form').focus();


Hope this helps!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900