Home All Groups Group Topic Archive Search About
Author
11 Sep 2007 3:04 AM
PJ
Greetings,

I ran into a slight problem. Let's say we have two classes like below:

---- START CODE ----
class foo
{
    private string __Text;
    private Unit __Unit;

    public foo()
    {
    }

    public string Text
    {
        get { return __Text; }
        set { __Text = value; }
    }

    public Unit Width
    {
        get { return __Unit; }
        set { __Unit = value; }
    }
}

class bar : WebControl
{
    private foo __Property1;
    private foo __Property2;

    public bar()
    {
        __Property1 = new foo();
        __Property1.Text = "Default Value 1";
        __Properyt1.Unit = new Unit(10, Pixel);

        __Property2 = new foo();
        __Property2.Text = "Default Value 2";
        __Properyt2.Unit = new Unit(100, Pixel);
    }

    public foo Property1
    {
        get { return __Property1; }
        set { __Property1 = value; }
    }

    public foo Property2
    {
        get { return __Property2; }
        set { __Property2 = value; }
    }

}

---- END CODE ----

The class 'foo' has only two properties: 'Text' and 'Width', strongly
typed and all. The class 'bar' has another two properties: 'Property1'
and 'Property2', both of them are of type 'foo'.

The problem is: How can I set the property attributes of 'Property1'
and 'Property2' of the class 'bar' in a way that the default values
specified on the 'bar' constructor doesn't get persisted.

As is the persistence of the class bar (for the default values --
let's make it perfectly clear) is something like:

---- START CODE ----

<cc1:bar ID="bar1" runat="server">
    <Property1 Text="Default Value 1" Width="10px">
    <Property2 Text="Default Value 2" Width="100px">
</cc1:bar>

---- END CODE ----

What I want is that with only the DEFAULT values of each property the
object to be persisted as:

---- START CODE ----

<cc1:bar ID="bar1" runat="server" />

---- END CODE ----

How can I do this with only attributes?

Regards,

PJ
http://pjondevelopment.50webs.com

AddThis Social Bookmark Button