By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,070 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,070 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

"Earl Teigrob" <ea******@hotmail.com> wrote in message
news:uJ**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #2

P: n/a
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
"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
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

"Earl Teigrob" <ea******@hotmail.com> wrote in message
news:uJ**************@TK2MSFTNGP10.phx.gbl...
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


Nov 18 '05 #3

P: n/a
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

"Earl Teigrob" <ea******@hotmail.com> wrote in message
news:e1*************@TK2MSFTNGP12.phx.gbl...
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
"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
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

"Earl Teigrob" <ea******@hotmail.com> wrote in message
news:uJ**************@TK2MSFTNGP10.phx.gbl...
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



Nov 18 '05 #4

P: n/a
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

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
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

"Earl Teigrob" <ea******@hotmail.com> wrote in message
news:e1*************@TK2MSFTNGP12.phx.gbl...
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
"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
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

"Earl Teigrob" <ea******@hotmail.com> wrote in message
news:uJ**************@TK2MSFTNGP10.phx.gbl...
> 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
>
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.