The TableCustomControlDemo Code-Behind Class File
using System;
namespace ControlsBook2Web.Ch02
{
public partial class TableCustomControlDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
TableCust1.X = 3;
TableCust1.Y = 3;
TableCompCust1.X = 3;
TableCompCust1.Y = 3;
}
CHAPTER 2 ?– ENCAPSULATING FUNCT IONALITY IN ASP.NET 75
}
}
}
Inheriting from an Existing Server Control
The previous examples are very simple controls in concept. This was by design; we focused on
the details required to build the simplest of controls in order to give you a taste of the controlbuilding
process. In this section, we demonstrate how, with just a little bit of code, it is possible
to add pleasing functionality through inheritance to one of the existing ASP.NET controls.
In this simple inheritance example, we??™ll add a 3-D look to the WebControl TextBox class. To
add this UI behavior, we take advantage of the DHTML features of Internet Explorer when
rendering our new server control. Listing 2-18 contains TextBox3d??™s class file.
Listing 2-18. The TextBox3d Class File
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.
Pages:
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144