Partial View in MVC is used when we want to use section for the master or the main page again and again.
It is just like a user control that is used to display or get data in the view that we want.
So as a beginner, you first need to create the MVC project .
After doing that you need to create a view for the index action
After doing this we will create a partial view named _EmployeePartial
public ActionResult _EmployeePartial()
{
Partial_View.Models.EmployeeModel obj = new Models.EmployeeModel();
obj.FirstName = "Himanshu";
obj.MiddleName = "Chandra";
obj.LastName = "Joshi";
return PartialView(obj);
}
Then we will create the partial view for this action.
After doing this we will render the partial view into our index view
<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="row">
<div class="col-md-4">
<h2>Getting started</h2>
<p>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and gives you full control over markup
for enjoyable, agile development.
</p>
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more »</a></p>
</div>
@{Html.RenderAction("_EmployeePartial", "Home");}
0 Comment(s)