The ControlsBook2MasterPage Master Page Code-Behind Class File
using System;
namespace ControlsBook2Web.MasterPage
{
public partial class ControlsBook2MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
In the master page for the Controls Book 2 web site, the chapter number and chapter title
have ContentPlaceHolder placeholder tags to allow content pages to update the chapter number
and title.
Each web form sets values for the chapter title and number by simply placing the value in
the corresponding Content tag in the content page. This is a simple example of providing a
consistent user interface in a web site, but still allowing customization.
CHAPTER 1 ?– SERVER CONTROL BASICS 5
?– Tip ASP.NET User Controls are still present in ASP.NET 3.5. In fact the MasterPage class inherits from
the UserControl class.
The resulting arrangement is shown in Figure 1-3 with a DropDownList control, a TextBox
control, two Label controls, and a Button control. The resulting source code generated by Visual
Studio 2008 is shown in Listings 1-3 and 1-4.
Figure 1-3. The HelloWorld server control web form
Listing 1-3. The HelloWorld Demo Web Form .aspx File
<%@ Page Language="C#"
MasterPageFile="~/MasterPage/ControlsBook2MasterPage.
Pages:
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52