在
Html 5中,文本框上有一个新的属性,称为autofocus.
问题是它是一个布尔值(有或没有)
它应该看起来像:
<input name="a" value="" autofocus>
我试过了 :
<%= Html.TextBox( "a",null,new { autofocus } ) %>
我知道我可以手动做,但可以用Html.TextBox吗?
解决方法
尝试<%= Html.TextBox(“a”,new {autofocus =“”})%>
根据HTML5 spec on boolean attributes:
If the attribute is present,its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute’s canonical name,with no leading or trailing whitespace.
所以也是
>< input name =“a”value =“”autofocus>要么
>< input name =“a”value =“”autofocus =“”>要么
>< input name =“a”value =“”autofocus =“autofocus”>
应该是有效的