0

I try to add id to textbox but get error. I should use Html.EditorFor() statement.Please advice.

My code:

@Html.EditorFor(model => model.Historicals.HistoricalName, new { htmlAttributes = new { @class = "form-control" } }, new { id = "Historical_place_name" })
4
  • 1
    It need to be @Html.EditorFor(m => m.Historicals.HistoricalName, new { htmlAttributes = new { @class = "form-control", id = "Historical_place_name"} }) Commented Mar 7, 2016 at 11:14
  • But what is wrong with using the id that is already added by the EditorFor() method? (which is id="Historicals_HistoricalName") Commented Mar 7, 2016 at 11:16
  • I use id for set style of lable and textbox in bootstrap. Commented Mar 7, 2016 at 11:17
  • 1
    So just use the default id value (which is Historicals_HistoricalName) Commented Mar 7, 2016 at 11:18

1 Answer 1

1

I believe you should add the id property to the html attributes.

@Html.EditorFor(m => m.Historicals.HistoricalName, 
    new { htmlAttributes = new { @class = "form-control", id = "Historical_place_name" } });
Sign up to request clarification or add additional context in comments.

1 Comment

Please delete " , null "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.