Custom control, defaulting style properties

Discussion in 'ASP .Net' started by Jeremy Chapman, Mar 7, 2006.

  1. 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(DesignerSerializationVisibility.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.BorderColor =
    System.Drawing.ColorTranslator.FromHtml("#000000");
    this.pCalCurrentMonthSelectedDateStyle_m.BorderWidth =
    new Unit(1, UnitType.Pixel);
    this.pCalCurrentMonthSelectedDateStyle_m.BorderStyle =
    BorderStyle.Solid;
    this.pCalCurrentMonthSelectedDateStyle_m.Font.Underline
    = true;
    if (base.IsTrackingViewState)
    {
    this.pCalCurrentMonthSelectedDateStyle_m.DoTrackViewState();
    }
    }
    return this.pCalCurrentMonthSelectedDateStyle_m;
    }
    }
     
    Jeremy Chapman, Mar 7, 2006
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.