Click here to Skip to main content
16,021,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Am using mvc3 razor cshtml file for design one popup window.
In that i need to focus cursor on first field using autofocus event.

This is the coding am tried,
HTML
<div class="contact_form">
<div class="contact_form1">
@Html.LabelFor(model => model.Increment)
</div>
@Html.TextBoxFor(model => model.Increment, new {autofocus="autofocus", @class = "name_form" })
@Html.ValidationMessageFor(model => model.Increment)
</div>

If am giving like this the cursor is foucs on the label(increment).but i need to focus on the cursor is text field.

Please help me resolve the problem.
Posted
Updated 21-Aug-12 19:53pm
v2
Comments
Sergey Alexandrovich Kryukov 22-Aug-12 2:13am    
Don't mix up focus and selection. "Focus" means the state of a control when Windows dispatch keyboard messages to it.
--SA

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