Add a Partialcontroller Controller
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingsystem.web;5 usingSYSTEM.WEB.MVC;6 7 namespacemvcvalidatedemo.controllers8 {9 Public classPartialcontroller:controllerTen { One // A //GET:/partial/ - - Publicactionresult Index () the { - returnView (); - } - + PublicActionResult About () - { + Aviewdata["Key"] ="Action executes the"; atViewbag.demo ="Action Bag Executes the"; - returnView (); - } - - } -}
Add about View
1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name="Viewport"Content="Width=device-width"/>Ten<title>About</title> One A<body> -<div> -About: @[email protected]["Key"] the</div> -</body> -
Add an index view
1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name="Viewport"Content="Width=device-width"/>Ten<title>Index</title> One A<body> -<div> - @{ theHtml.renderpartial (" About");//the handle view renders to the current position - -Html.renderaction (" About");//renders the result of the action to the current position - } +</div> -</body> +
The difference between html.renderpartial and html.renderaction