MVC newbie question re binders. Suppose I have two strongly typed partial actions that have model attributes with the same name and appear on the same ie page:
Class Friend {string Name {get; set ;} DateTime DOB {get; set ;}}
Class Foe {string Name {get; set ;} string ReasonForDislike {get; set ;}}
Both particles will have a line:
<%= Html.TextBoxFor(model => model.Name) %>
And related actions with the controller:
public ActionResult SaveFriend(Friend friend)
public ActionResult SaveFoe(Foe foe)
My problem is that both will appear on my containing page with the same id (of course, bad for many reasons). Im aware of the [Bind] attribute, which allows me to add a prefix, with the result that the code appears:
public ActionResult SaveFriend([Bind(Prefix = "friend")] Friend friend)
<%= Html.TextBox("friend.Name", Model. Name) %>
But it still doesnβt cut. I can just suffer the loss of the strongly typed TextBoxFor helpers, but Ive not yet received a client check for working with prefixes: Ive tried:
<%= Html.ValidationMessage("friend.Name") %>
... and any other option I can think of.
, , , . () , . ?
.