How can I generate the following input element using standard HTML helpers and Razor view engine:
<input id="Foo" name="Foo" type="text" autofocus />
Can I use the standard HTML helper or do I have to write my own?
Any help would be greatly appreciated!
You can pass additional HTML attributes to the TextBoxFor method:
Edit:
You can get only
autofocus=""with:All the built in helpers are using the TagBuilder class’s MergeAttribute method internally, and it only supports attributes in the following format :
key="value".So if you need only
autofocusyou need to write your own helper with a custom html builder.