In Razor I can turn off Autocomplete on a textbox by doing this:
@Html.EditorFor(model => model.UserName, new { autocomplete = "off" })
Is there a way I can specify this in the ViewModel using DataAnnotations instead of in the View?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think there is a standard way to manipulate html attributes from ViewModel attributes with the
EditorForextension method.However, you can create a custom html helper method if you want to keep it DRY.
Btw I don’t think that it would be a great idea to encapsulate these kind of informations (html attributes) inside a ViewModel class.