all groups > asp.net building controls > october 2003 >
You're in the

asp.net building controls

group:

WebControl with derived propertied is not saving partial property in the HTML


WebControl with derived propertied is not saving partial property in the HTML c_zachariadis NO[at]SPAM hotmail.com
10/28/2003 5:49:04 AM
asp.net building controls:
Weird, here is a code example:
If you make a brand new web control that has a property of type ITest2
and you create Test2 in there. Lets say I set both properties of Test2
to some string. When I flip to the HTML page I only see the property
DestObject which is defined in ITest2 but I don't see the property
from ITest1. So, when I close and reopen the form my
ITest1.SourceObject property is blank again.
Any ideas?

Thanks

CZ

public interface ITest1
{
string SourceObject
{
get; set;
}
}

public interface ITest2: ITest1
{
string DestObject
{
get; set;
}
}

[SerializableAttribute]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Test1: Itest1
{
protected string _SourceObject="";
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[NotifyParentProperty(true)]
[DefaultValue("")]
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public string SourceObject
{
get {return _SourceObject;}
set {_SourceObject = value; }
}
}

[SerializableAttribute]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Test2: Test1, ITest2
{
protected string _DestObject="";
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[NotifyParentProperty(true)]
[DefaultValue("")]
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public string DestObject
{
get {return _DestObject;}
set {_DestObject = value; }
}
}

//======================================
// WEB CONTROL
//======================================

public class TestControl: WebControl
{
protected ITest2 _Test2;

[Browsable(true)]
[Category("Data")]
[DesignerSerializationVisibility
DesignerSerializationVisibility.Content)]
[NotifyParentProperty(true)]
public ITest2 MyTest2 {
get {
if (_Test2 == null )
{
_Test2 = new Test2();
}
return this._Test2;
}
}
Re: WebControl with derived propertied is not saving partial property in the HTML c_zachariadis NO[at]SPAM hotmail.com
10/28/2003 2:25:22 PM
Basically, properties that are based on derived interfaces only
serialize the latest interface properties and none of the ancestor
properties. I verified this by not inheriting from a base interface.
Instead I added all the ancestor properties to the derived interface
and they all serialized properly!
Amazing, I hope it's something simple and not a bug.

Re: WebControl with derived propertied is not saving partial property in the HTML c_zachariadis NO[at]SPAM hotmail.com
10/29/2003 6:27:49 AM
Anyone, please? This is important.

Thanks

AddThis Social Bookmark Button