I'm building a web custom control in which I'm trying to include an enum for one of the properties as follows:
//-------------------------
public enum LocationType
{
NotSet,
Client,
Server,
Both
}
[
Category("ACFragment Defaults"),
DefaultValue(LocationType.Client),
Description ("location where the content is stored"),
DesignerSerializationVisibility (DesignerSerializationVisibility.Content),
NotifyParentProperty(true)
]
public virtual LocationType ACDefaultLocation
{
get
{
object o = ViewState["ACDefaultLocation"];
return (o == null) ? LocationType.Client : (LocationType)o;
}
set
{
ViewState["ACDefaultCacheLocation"] = value;
}
}
//----------------------
The enum correctly displays as a drop down in design mode and once selected the value shows up correctly in the html design form. However, when the application runs the control always retrieves the default value rather then the value selected in the drop down.
My guess is that I'm missing Enum.ToObject(typeof(LocationType), value) in the get method. However, that would cause problems in the design mode.
I've seen references to TransitionStyleObjectConverter in this forum which should help but I can't figure out how to implement it into the above scenario.
Please let me know how to make this work,
Mike
- Cache entire web sites at the client and server and keep cache current. Cache just got easier!