Setting a Custom Control Property that is an enumeration (or other non primative type) from aspx pa

  • Thread starter Thread starter Earl Teigrob
  • Start date Start date
E

Earl Teigrob

I have a property set in my templated custom control as follows

public System.Drawing.Color tableColor;
public System.Drawing.Color TableColor
{
set
{
tableColor = value;
}
get
{
return tableColor;
}
}

In my Page Code, I would like to set the property to the color I want, Like
this (Except using code that works)

<cc:SpacerControl id="SpacerControl1"
TableColor="System.Drawing.Color.Red" runat="server">
<ItemTemplate>
Spacer Control
</ItemTemplate>
</cc:SpacerControl>

Is this possible???

Thanks

Earl
 
This will not work.

You will have two publicly defined things (I can't think of the term) that
are cardinally the same.(only differ in case)

tableColor and TableColor.

So when the .aspx parser is executing, it doesn't know what to set. The
field called tableColor or the property called TableColor.

One solution is to declare the field private, or come up with another name.

Also I belive you can get away in your aspx file from just assigning
TableColor="red"

HTH,

bill
 
Bill, you are correct, the field defintion was supposted to be private, not
public. I just created this example for demonstration purposes and missed
that...and yes, just assigning the enum name worked fine...

Earl
 
So then what was your question? I wasn't trying to nit pick your code, I
wasn't sure if that is what you were driving at.

bill
 
Bill, You answered my question, Thank You! I was getting to complicated in
trying to assign an enum value. Just use the value itself. Thats all I
needed.

Earl
 
Back
Top