Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:-

C#
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:

C#

@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
Posted
Comments
Jameel VM 25-Aug-13 12:29pm    
what 's the pblm?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900