Prev | Current Page 134 | Next

Rob Cameron and Dale Michalk

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

NET.
We make this property available so that it is possible to revert to the TextBox base class??™s look
and feel without having to swap out the control. The property uses ViewState, which we cover in
Chapter 3, to store the value, with a default value of true set in the control??™s constructor.
The only other interesting code in this simple control is the Render() method. Here, we add a
style attribute to the output variable to provide the 3-D look to the base TextBox control. We round
out this method with a call to the base class??™s Render() method to finish off all the work.
As in previous examples, we need an .aspx page to host our custom control and show off
our new 3-D look. Figure 2-11 shows the 3-D TextBox at runtime.
Figure 2-11. Output from the TextBox3dDemo web form
CHAPTER 2 ?–  ENCAPSULATING FUNCT IONALITY IN ASP.NET 77
Listings 2-19 and 2-20 contain TextBox3dDemo??™s .aspx and class files, respectively.
Listing 2-19. The TextBox3dDemo Web Form .aspx File
<%@ Page Language="C#" MasterPageFile="~/MasterPage/ControlsBook2MasterPage.Master"
AutoEventWireup="true" CodeBehind="TextBox3DDemo.aspx.cs"
Inherits="ControlsBook2Web.Ch02.TextBox3DDemo"
Title="TextBox3D Demo" %>
<%@ Register TagPrefix="apress" Namespace=
"ControlsBook2Lib.


Pages:
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146