Articles → ASP .NET MVC → Partial Views In Asp.Net MVC

Partial Views In Asp.Net MVC






Creation Of Partial Views




  1. Right click on the view\shared folder and click on Add – View..
  2. Picture showing Add -> View... option in context menu
    Click to Enlarge



  3. Add View’ appears, check on ‘Create as partial view’ checkbox as shown in the following figure
  4. Picture showing the popup window to add new view
    Click to Enlarge

  5. Click on ‘Add’. A partial view will be added in shared folder.
  6. Inside the partial view class, add following code
  7. <table>
       <tr>
          <td><a href="http://google.com" target="_blank">Google</a></td>
       </tr>
       <tr>
          <td><a href="http://bing.com" target="_blank">Bing</a></td>
       </tr>
    </table>



Adding Partial View In The View




@{
ViewBag.Title = "Home Page";
}
@Html.Partial("SideBar")



Output




Picture showing the output of partial views in asp.net mvc
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, September 24, 2015

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250