Chapter 11User Controls and Partial Views

What you will learn in this chapter:

  • What an ASP.NET Web Forms user control is, and how to use it in a website
  • Creating user controls that provide common functionality to multiple pages
  • Creating an ASP.NET MVC partial view and using it in your web application
  • Working with controllers that return partial views
  • How user controls and partial views differ
  • Creating ASP.NET MVC templates

Code Downloads for this Chapter:

The code downloads for this chapter are found at on the Download Code tab. The code is in the chapter 11 download and individually named according to the names throughout the chapter.

There was a lot of discussion in Chapter 4, “Programming in C# and VB.NET,” about reusing the same code in multiple areas as opposed to rewriting the code multiple times. This is a useful concept not only when approaching your code design, but also when approaching your page design. You have seen how reuse is provided through the use of master pages and layout pages; now you will learn other ways to provide reusable sections in a web application.

A typical example of this could be something like a login window. While you may want the same functionality on every page, you might prefer that functionality to appear in different places on the page, based on the visitor's current location. Because they may be on different parts of the page, it's not possible to put this functionality into the ...

Get Beginning ASP.NET for Visual Studio 2015 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.