I’m trying to set id and name for @Html.EditorFor, but this isn’t working:
@Html.EditorFor(model => model.value, new { @id = "testid1", @name="testname1"})
How do I set id and name?
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.
EditorFordoes not allow for adding htmlAttributes. For the specific types of editors you’ll have to useTextBoxFor(or whatever type you’re using).You can also create a custom editor template for the particular type you’re creating an editor for.