如何使用 Html.EditorFor 语句将 id 添加到文本框?

How to add id to textbox with Html.EditorFor statement?

我尝试将 id 添加到文本框,但出现错误。我应该使用 Html.EditorFor() statement.Please 建议。

我的代码:

@Html.EditorFor(model => model.Historicals.HistoricalName, new { htmlAttributes = new { @class = "form-control" } }, new { id = "Historical_place_name" })

我认为您应该将 ID 属性 添加到 html 属性。

@Html.EditorFor(m => m.Historicals.HistoricalName, 
    new { htmlAttributes = new { @class = "form-control", id = "Historical_place_name" } });