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

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
 
W

William F. Robertson, Jr.

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
 
E

Earl Teigrob

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
 
W

William F. Robertson, Jr.

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
 
E

Earl Teigrob

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top