Sponsored by Gluten Free Waffles and Sliced Bananas

Tuesday, March 30, 2010

ASP.NET MVC: DRY Design with Partial Views

6:44 PM Posted by Tyson Nero No comments
The use of partial views in MVC is an example of DRY (Do Not Repeat Yourself) design. Partial Views are comparable to user controls in Web Forms and also share the same .ascx extension.

To create a partial view, simply check Create a partial view (.ascx) when adding a new view. Copy any implementation into the new view that you would like to share across other views. To render your partial view in other views, use the below syntax:

<% Html.RenderPartial("PartialViewName"); %>


Post a Comment