Prev | Current Page 365 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"


The .NET Framework also provides the ability to visually edit templates, and the
Designer(typeof(TemplateMenuDesigner))] attribute applied to the TemplateMenu class provides
this support for the TemplateMenu server control.
This custom designer, which we cover in detail in Chapter 11, adds an Edit Templates
menu item to the task list for the control. Click the task arrow when the control is selected in
the designer; click Edit Template; and then choose the template you want to edit. This brings
up a visual UI for the template, where you can drag and drop other ASP.NET controls, such as
an image control for the separator template, and edit the style for the template in the Properties
tool window. Figure 6-6 shows the results of our control after customizing its templates.
Listings 6-4 and 6-5 contain the .aspx file and code-behind class for the TemplateMenu web
form, respectively.
Figure 6-6. The TemplateMenu web form displayed in a browser
CHAPTER 6 ?–  SERVER CONTROL TEMPLATES 267
Listing 6-4. The TemplateMenu Web Form .aspx File
<%@ Page Language="C#"
MasterPageFile="~/MasterPage/ControlsBook2MasterPage.Master"
AutoEventWireup="true" CodeBehind="TemplateMenu.aspx.cs"
Inherits="ControlsBook2Web.Ch06.TemplateMenu"
Title="Template Menu Control Demo" %>
<%@ Register TagPrefix="apress" Namespace="ControlsBook2Lib.


Pages:
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377