Asp.Net Mvc - Html.TextBox - Set Autofocus property
问题 In Html 5, there is a new attribute on textbox called autofocus. The problem is that it is a boolean value (there or not there) It should look something like : <input name="a" value="" autofocus> I tried : <%= Html.TextBox( "a", null, new { autofocus } ) %> But, it gives me an error because I'm not setting a value to autofocus... I know I can do it manually, but can I do it with Html.TextBox ? 回答1: Try <%= Html.TextBox( "a", null, new { autofocus = "" } ) %> According to the HTML5 spec on