Reputation: 6945
For attribute="value" I use
@Html.TextBoxFor(x => x.Email, new { type = "email", @class = "form-control",
placeholder="Email address" })
it gives me:
<input class="form-control" id="Email" name="Email" placeholder="Email address"
type="email" value="" />
How can I add single attribute to that, so I need required and autofocus:
<input class="form-control" id="Email" name="Email" placeholder="Email address"
type="email" value="" required autofocus />
Thanks!
Upvotes: 1
Views: 188
Reputation: 7740
If you use string.Empty
you will get an empty attribute in the generated html
@Html.TextBoxFor(x => x.Email, new { type = "email", @class = "form-control",
placeholder = "Email address", required = string.Empty, autofocus = string.Empty })
Upvotes: 4