ascx
file, we are looking for an assembly and namespace that contains the code of the custom control:
<%@ Register TagPrefix="apress" Namespace="ControlsBookLib.Ch02"
Assembly="ControlsBookLib" %>
You have to remember to make the control assembly, like ControlsBookLib in this example,
available to the web application either through the GAC or the web application??™s bin directory.
If things are set up properly, the MenuCustomControl provides an accurate representation in the
Design view of its HTML output, as shown in Figure 2-7.
64 CHAPTER 2 ?– ENCAPSULATING FUNCT IONALITY IN A SP.NET
Figure 2-7. The Visual Studio Design view of the MenuCustomControl on a web form
Figure 2-8 confirms that the HTML output from our MenuCustomControl custom server control
is the same as that of the user control in a browser. Listing 2-13 presents MenuCustomControlDemo??™s
.aspx file.
Figure 2-8. Output from the menu custom control demonstration web form
CHAPTER 2 ?– ENCAPSULATING FUNCT IONALITY IN ASP.NET 65
Listing 2-13. The MenuCustomControlDemo Web Form .aspx File
<%@ Page Language="C#" MasterPageFile="~/MasterPage/ControlsBook2MasterPage.Master"
AutoEventWireup="true" CodeBehind="MenuCustomControlDemo.aspx.cs"
Inherits="ControlsBook2Web.
Pages:
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131