I am new to MVC 4 and razor. I have a view which contains multiple partial views. Due to the functionality of the partial views I am planning to reuse these in other views also. My model is a collection of complex objects e.g:-
public class EmployeeInfo
{
public EmployeeContactInfo contactInfo { get; set; }
public List<TelephoneInfo> phoneDetails { get; set; }
public AddressDetails addressDetails { get; set; }
}
The model of my main view is "EmployeeInfo" and other partial views have models as "TelephoneInfo", "EmployeeContactInfo" and "AddressDetails" respectively.
I tried using "RenderPartial", "RenderAction" and "Partial" to load my partial views e.g:
@using (Html.BeginForm())
{
@Html.Partial("ContactInfo",Model.contactInfo)
}
When the main form is submitted the main model doesnt have the updated values of the partial views. I searched for this and found below 2 proposed solutions:-
i) Using EditorFor - It works and the model gets updated but I have collection of not only textbox but other controls which have some internal operations (like searching addresses) too also I need to reuse the same partial view in other places (same like user control in classic ASP.NET)
ii) using RenderAction instead of RenderPartial - It didnt work for me
Please let me know if I am going wrong or understood anything incorrectly Thanks in advance