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. Advertisements

  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. Advertisements

  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. Advertisements

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. Henri
    Replies:
    0
    Views:
    499
    Henri
    May 17, 2004
  2. Jonah Olsson
    Replies:
    1
    Views:
    769
    Scott Allen
    Apr 5, 2005
  3. Lee Harr
    Replies:
    1
    Views:
    325
    Lee Harr
    May 8, 2004
  4. puvit82
    Replies:
    4
    Views:
    999
    puvit82
    Feb 1, 2008
  5. Nathan Sokalski

    Entering an enumeration type as a property

    Nathan Sokalski, Nov 4, 2009, in forum: ASP .Net
    Replies:
    6
    Views:
    588
    Herfried K. Wagner [MVP]
    Nov 7, 2009
  6. Jeremy Chapman

    Custom control with complex property type (System.Web.UI.Control[])

    Jeremy Chapman, Feb 15, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    270
    Jeremy Chapman
    Feb 15, 2006
  7. Jonah Olsson
    Replies:
    2
    Views:
    375
    Jonah Olsson
    Apr 5, 2005
  8. Peter Michaux
    Replies:
    1
    Views:
    169
    Richard Cornford
    Oct 30, 2006
Loading...