The problem is this: when I put 2 controls of the same type on the page, I need to specify different prefixes for the binding. In this case, the validation rules created immediately after the form are incorrect. So, how to get the job of checking the client for the case ?:
page contains:
<%
Html.RenderPartial(ViewLocations.Shared.PhoneEditPartial, new PhoneViewModel { Phone = person.PhonePhone, Prefix = "PhonePhone" });
Html.RenderPartial(ViewLocations.Shared.PhoneEditPartial, new PhoneViewModel { Phone = person.FaxPhone, Prefix = "FaxPhone" });
%>
ViewUserControl <PhoneViewModel> control:
<%= Html.TextBox(Model.GetPrefixed("CountryCode"), Model.Phone.CountryCode) %>
<%= Html.ValidationMessage("Phone.CountryCode", new { id = Model.GetPrefixed("CountryCode"), name = Model.GetPrefixed("CountryCode") })%>
where it Model.GetPrefixed("CountryCode")simply returns "FaxPhone.CountryCode" or "PhonePhone.CountryCode" depending on the prefix
, . "Phone.CountryCode". - 2 (, ) "FaxPhone.CountryCode", "PhonePhone.CountryCode",
alt text http://www.freeimagehosting.net/uploads/37fbe720bf.png
Asp.Net MVC2 Clientside
.