Reset();
if (ViewState["cursor"] != null)
{
ViewState.Remove("cursor");
}
}
CHAPTER 4 ?– THE WEBCONTROL BASE C LASS AND CONTROL STYLES 171
// Hide base class version of IsEmpty using the keyword "new"
//and provide our own
// The keyword "internal" limits access to within the assembly only,
//following the pattern
// established by the base Style class
protected internal new bool IsEmpty
{
get
{ // Call base class version to get default behavior
return base.IsEmpty && (ViewState["cursor"] == null);
}
}
override public void AddAttributesToRender
(HtmlTextWriter writer, WebControl owner)
{
base.AddAttributesToRender(writer, owner); // Ensure base Style class adds its
// attributes to the output stream
if (ViewState["cursor"] != null)
{
string cursor =
Enum.Format(typeof(CursorStyle), (CursorStyle)ViewState["cursor"], "G");
writer.AddStyleAttribute("cursor", cursor);
}
}
}
}
The FancyLabel Control
The FancyLabel control is our choice for implementing the wonderful cursor capability of the
FancyLabelStyle style class. It inherits the code from our Label example earlier in the chapter.
We take it into the garage for an overhaul to gain the new style capabilities.
The first upgrade for FancyLabel is overriding the ControlStyle property creation logic.
Pages:
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266