I have a custom control with a property of type
System.Web.UI.WebControls.Style. In my property I've defaulted values of
the style if nothing has been sent. This gives my control a default look
but allows the user to override. My problem is, that the default values
persist to the aspx page even when they are not overwridden. It's not a huge
issue but really the values should only persist when overridden, just to
keep the aspx code small.
Code for my property:
private DatePickerStyle pCalCurrentMonthSelectedDateStyle_m;
[PersistenceMode(PersistenceMode.InnerProperty),
Category(strCATEGORY_STYLES),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
NotifyParentProperty(true)]
public DatePickerStyle CalendarCurrentMonthSelectedDateStyle
{
get
{
if (this.pCalCurrentMonthSelectedDateStyle_m == null)
{
this.pCalCurrentMonthSelectedDateStyle_m = new
DatePickerStyle();
this.pCalCurrentMonthSelectedDateStyle_m.ForeColor =
System.Drawing.ColorTranslator.FromHtml("#217092") ;
this.pCalCurrentMonthSelectedDateStyle_m.BackColor =
System.Drawing.ColorTranslator.FromHtml("#D5D5D5") ;
this.pCalCurrentMonthSelectedDateStyle_m.BorderCol or =
System.Drawing.ColorTranslator.FromHtml("#000000") ;
this.pCalCurrentMonthSelectedDateStyle_m.BorderWid th =
new Unit(1, UnitType.Pixel);
this.pCalCurrentMonthSelectedDateStyle_m.BorderSty le =
BorderStyle.Solid;
this.pCalCurrentMonthSelectedDateStyle_m.Font.Unde rline
= true;
if (base.IsTrackingViewState)
{
this.pCalCurrentMonthSelectedDateStyle_m.DoTrackVi ewState();
}
}
return this.pCalCurrentMonthSelectedDateStyle_m;
}
}