0

I have to make a form consisting of several sub forms which may or may not contain grids. For simplicity lets say i am using 2 models 1. Applicant Detail : where the applicants basic information (Name, DOB, Gender) is placed. 2. Applicant Experience : where the applicants prev work experience details are being placed.

Now for organizing purpose i am thinking of making two different controllers Namely ApplicantDetail and ApplicantExperience and both will contain their respective functionalities. But as soon as the user enters his basic information i want the same view to call in the index view of ApplicantDetail which will have a grid and the user can enter his/her prev working details in the form of rows.

My basic question is, is there anyway that can i create single razor view which will contain the razor view of my ApplicantDetail as well??

4

1 回答 1

1

I believe what you are looking for is RenderAction.

Using RenderAction you can invoke controller/view within any view.

So if you had some razor view and second Controller and View combination, you could invoke it like so within the first view:

@{ Html.RenderAction("Action", "Controller2"); }

This can be useful when trying to modularize functionality.

See this blog post from Phil Haack for more details: Html.RenderAction and Html.Action

于 2011-08-04T00:21:34.610 回答