all groups > asp.net building controls > april 2004 >
You're in the

asp.net building controls

group:

Serialiazing CollectionBase



Serialiazing CollectionBase Victor Irzak
4/29/2004 1:34:29 PM
asp.net building controls: Hello...
I the following class deriving from CollectionBase:

============================
public class YYYepC : System.Collections.CollectionBase
{
int i = 9;

[DefaultValue(4)]
[PersistenceMode(PersistenceMode.Attribute)]
public int I
{
get {return i;}
set {i=value;
}
}
}
============================

When I try to serialize it in my web control, the "I" property doesn't get
serialized. Only the sollection items get serialized.

Here is my control:
============================
public class WebChartingControl : System.Web.UI.WebControls.WebControl
{

YYYepC da2 = new YYYepC();

[PersistenceMode(PersistenceMode.InnerProperty)]
[NotifyParentProperty(true)]
public YYYepC YYYepC
{
get {return da2;}
set {da2 = value;}
}
}
============================


How can I serialize all the other properties?

Thanks,

Victor

Re: Serialiazing CollectionBase Fred Hirschfeld
4/29/2004 6:59:24 PM
I don't think I can answer your question but might be able to point you in
the right direction... Collections are intended to be serialized as items to
the Control when used this way. I use them to serialize inner tags to be
used by the control like the DataGrid uses Columns.

I think you are going to need to create a custom designer to process the
collection class so it does the properties of the collection instead of the
items of the collection. Take a look into DesignerSerializerAttribute class
to see if there are examples for it out there...

Fred

[quoted text, click to view]

AddThis Social Bookmark Button