A partial view, which is part of the overall view. A single view page is displayed above the overall page, using the steps below
1. Creating View data is ViewModel
Public class Footerviewmodel { publicstringgetset;} Public string Get Set ; } }
2. Create a partial view. New View--Select a partial view and write the following code for the partial view: (Strongly typed view)
@using Mymvc3demo.viewmodels@model Footerviewmodel <div style="text-align:right;background-color:silver;color:darkcyan;border:1px solid gray; margin-top:2px;padding-right:10px; "> @Model. Companyname© @Model.year </div>
3. View page reference
@{ html.renderpartial ("Footer", Model.footerdata); }
Of course the page can
@Html. Partial ("Footer", Model.footerdata)
The difference between 1>, renderpartial, and partial is that Html.renderpartial writes the results of the partial view directly to the HTTP response stream, and html.partial returns the Mvchtmlstring value. In other words, the renderpartial has no return value, the output is written directly in the HTTP corresponding stream, while the partial has a return value, the returned string is written directly on the page, and finally output to the HTPP response stream.
2>html.renderaction (""), the method is a page call method, the page through renderaction the request to action, let the action output after the result is written to the HTPP response stream.
Html.renderaction ("Getaddnewlink");
MVC partial view (partial views)