Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys, I'm gonna create profile page for my site. This page includes some 'Partial View' and each part posts some data.

My question is: How can I get posted data (strongly typed) from each partial view separately?

Something like this:

[HttpPost] 
public ActionResult Home(Model1 model1, Model2 model2, ...) 
{ 
return View(); 
}


and also is there any better way?

Thanks in advance
Posted

1 solution

So. I see no problem here. Originally MVC solves this issue. You create strongly typed view ProfilePage which will contain several partial views with its own models (Model1 model1, Model2 model2, ..., ModelN modelN). Your ProfilePage view model will be of MainModel type:

public class MainModel
{
   public Model1 model1{get;set;}
   public Model2 model2{get;set;}
   //
   //   ...
   //
   public ModelN modelN{get;set;}
}


You dont need to get posted data. The controller should implement it and then procces posted data.
 
Share this answer
 

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