I have a custom control with a panel wrapping all the other controls. The control is in one of two states, edit-mode and normal. When in edit-mode I want the control to have the option of a different background color.
I have:
In Pre_Render:
Panel1.BackColor = EditMode ? BackEditColor : BackColor;
And the control properties:
[Bindable(true)]
[Category("Misc")]
[Description("The background color.")]
[DefaultValue("white")]
[Localizable(true)]
public Color BackColor
{
get { return Color.FromName(Convert.ToString(ViewState["BackColor"] ?? "white")); }
set { ViewState["BackColor"] = value.Name; }
}
[Bindable(true)]
[Category("Misc")]
[Description("The edit-mode background color.")]
[DefaultValue("#FFFFCC")]
[Localizable(true)]
public Color BackEditColor
{
get { return Color.FromName(Convert.ToString(ViewState["BackEditColor"] ?? "#FFFFCC")); }
set { ViewState["BackEditColor"] = value.Name; }
}
I can set the colors with no problem via the control’s properties, but they only show as white on render. How should I be saving/reading to ViewState the colors?
How about just: