Prev | Current Page 224 | Next

Rob Cameron and Dale Michalk

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

ForeColor = c;
// set the text-decoration CSS style properties
// using manual manipulation of the Style property
string textdecoration = "none";
if (UnderlineCheckbox.Checked == true)
textdecoration = "underline";
NameLabel.Style["text-decoration"] = textdecoration;
}
}
}
Listing 4-5. The WebControlStyle.css File
.yellowbackground
{
background-color: #ffff66;
}
.grayborder
{
border-right: gray thin groove;
padding-right: 2px;
border-top: gray thin groove;
padding-left: 2px;
padding-bottom: 2px;
border-left: gray thin groove;
padding-top: 2px;
border-bottom: gray thin groove;
}
144 CHAPTER 4 ?–  T HE WEBCONTROL BASE CLASS AND CONTROL S TYLES
The Set Style button on the Web Control Style web form is used to programmatically change
the style properties of the Label control in the code-behind file. The SetStyleButton_Click
routine performs the heavy lifting. The attributes set are fairly easy ones that include the Text-
and Font-related properties, along with the CssClass of the control.
A more complicated effort is required to set up the ForeColor property of the control to a
value of type System.Drawing.Color. We use the TypeConverter class that is available to perform this
conversion from our string value to the exact Color type necessary to set the ForeColor property:
// Use the TypeConverter for the System.


Pages:
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236