Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
756 views
Welcome To Ask or Share your Answers For Others

1 Answer

 @Html.EditorFor(model => model.Beds[i].BedName, new { htmlAttributes = new { @class = "form-control", Name = "BedName" + Model.Beds[i].bedId, @id = "BedName" + Model.Beds[i].bedId } })

Use Name insted of @name and add htmlAttributes in your code its working for me


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...