Because the theme is set early in the page’s life cycle, this setting is applied throughout the page, effectively
giving the page the look and feel defined in it. To ensure that the code doesn’t try to apply a
theme that (no longer) exists, it uses Directory.Exists that returns true or false depending on the
presence of the folder on disk. To get at the full path of the theme folder on disk, it uses Server
.MapPath to translate a virtual path into its physical counterpart. You learn more about virtual paths
in the next chapter, while Server.MapPath is discussed further in Chapter 9.
With the capability to set the theme programmatically, you’re offering your users a quick and easy
way to change the page to their liking. The theme affects colors and layout throughout each page in
the entire website. Combined with master pages, this gives you a flexible way to influence the look
and feel of an entire page. It could also be useful if you were able to change certain controls on a
page. For example, you may have the need to give each button in your site the exact same look. This
is where the ASP.NET skins come into play.