Monday, November 08, 2004

Web Custom Control Loses Nested Property Values......

When writing web custom controls, we might have the use for some nested property values, (Ex: Style property).
These properties tend to lose their values if they are not persisted.
So include the Persistance attribute to the property to describe how the property wil be persisted.

PersistenceMode(PersistenceMode.InnerProperty)
*************************************************
Sample Property:

private Style cc;

[Bindable(true),
Category("Appearance"),
DefaultValue(""),
PersistenceMode(PersistenceMode.InnerProperty)
]
public Style myColor
{
get
{
return cc;
}
set
{
cc = value;
}
}


This persists the property values as nested tags inside the Control's tag.

MSDN Link - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuipersistencemodeclasstopic.asp

No comments: