for example, in a Action, I get data and it will be shown in two different place, so I create two partial views, ViewA and ViewB. So the question is: how to return partial view ViewA and ViewB in the Action?
-
1One Action Method can return only one View/Partial view.Bappi Datta– Bappi Datta2014-02-10 04:52:19 +00:00Commented Feb 10, 2014 at 4:52
-
Click this link: stackoverflow.com/questions/6937156/…Bappi Datta– Bappi Datta2014-02-10 04:53:49 +00:00Commented Feb 10, 2014 at 4:53
-
Possible duplicate of - stackoverflow.com/questions/21625002/…. But check the solution, with a custom extension of PartialViewResult, you can get your job done.ramiramilu– ramiramilu2014-02-10 06:16:41 +00:00Commented Feb 10, 2014 at 6:16
Add a comment
|
1 Answer
If I understood your question correctly ...
Firstly, you can't return multiple views from a action since there can't be multiple return from a method. So to address your issue, create a model 'MODEL' with subclasses 'MODELA' and 'MODELB' in it catering the models for ViewA and ViewB. Create a view 'MainView', render the partial views ViewA and ViewB in 'MainView' using @Html.Partial. While rendering viewA and viewB, pass @Model.MODELA and @Model.MODELB respectively.