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

Discussion in 'ASP .Net' started by Earl Teigrob, May 14, 2004.

  1. Earl Teigrob

    Earl Teigrob Guest

    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
    Earl Teigrob, May 14, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    >
    >
    >
    William F. Robertson, Jr., May 14, 2004
    #2
    1. Advertising

  3. Earl Teigrob

    Earl Teigrob Guest

    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." <> wrote in message
    news:uUBW$...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >

    >
    >
    Earl Teigrob, May 14, 2004
    #3
  4. 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" <> wrote in message
    news:...
    > 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." <> wrote in message
    > news:uUBW$...
    > > 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" <> wrote in message
    > > news:...
    > > > 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
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    William F. Robertson, Jr., May 14, 2004
    #4
  5. Earl Teigrob

    Earl Teigrob Guest

    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." <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    > > 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." <> wrote in message
    > > news:uUBW$...
    > > > 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" <> wrote in message
    > > > news:...
    > > > > 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
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Earl Teigrob, May 19, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kirby
    Replies:
    3
    Views:
    621
    Kirby
    Oct 8, 2004
  2. Replies:
    16
    Views:
    519
    James Kanze
    Oct 1, 2007
  3. puvit82
    Replies:
    4
    Views:
    742
    puvit82
    Feb 1, 2008
  4. Nathan Sokalski

    Entering an enumeration type as a property

    Nathan Sokalski, Nov 4, 2009, in forum: ASP .Net
    Replies:
    6
    Views:
    416
    Herfried K. Wagner [MVP]
    Nov 7, 2009
  5. Peter Michaux
    Replies:
    1
    Views:
    91
    Richard Cornford
    Oct 30, 2006
Loading...

Share This Page