Enum Property

Discussion in 'ASP .Net Web Controls' started by brandonjack007@gmail.com, Jul 31, 2007.

  1. Guest

    I have an enum property in web control. I can set it to One, Five,
    Fifteen. It always returns "One" at runtime. Any suggestion.

    public enum Interval
    {
    One,
    Five,
    Fifteen
    }

    [Bindable(true),
    Category("Appearance"),
    Description("Sets Minute Interval. Permissible values are One,
    Five, Fifteen"),
    DefaultValue(""),

    DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    PersistenceMode(PersistenceMode.Attribute)]
    public virtual Interval MinuteInterval
    {
    get
    {
    object result = this.ViewState["MinuteInterval"];
    if (result != null)
    return (Interval)result;
    else
    return Interval.One;
    }
    set
    {
    ViewState["MinuteInterval"] = value;
    }
    }
    , Jul 31, 2007
    #1
    1. Advertising

  2. Scott M. Guest

    It looks to me like ViewState["MinuteInterval"] is not getting a value in
    the first place, causing you to always return "one". Why not try using your
    enum with a simple property first and then move on to ViewState values?


    <> wrote in message
    news:...
    >I have an enum property in web control. I can set it to One, Five,
    > Fifteen. It always returns "One" at runtime. Any suggestion.
    >
    > public enum Interval
    > {
    > One,
    > Five,
    > Fifteen
    > }
    >
    > [Bindable(true),
    > Category("Appearance"),
    > Description("Sets Minute Interval. Permissible values are One,
    > Five, Fifteen"),
    > DefaultValue(""),
    >
    > DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    > PersistenceMode(PersistenceMode.Attribute)]
    > public virtual Interval MinuteInterval
    > {
    > get
    > {
    > object result = this.ViewState["MinuteInterval"];
    > if (result != null)
    > return (Interval)result;
    > else
    > return Interval.One;
    > }
    > set
    > {
    > ViewState["MinuteInterval"] = value;
    > }
    > }
    >
    Scott M., Jul 31, 2007
    #2
    1. Advertising

  3. marss Guest

    On 31 , 02:59, wrote:

    > [Bindable(true),
    > Category("Appearance"),
    > Description("Sets Minute Interval. Permissible values are One,
    > Five, Fifteen"),
    > DefaultValue(""),
    >
    > DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    > PersistenceMode(PersistenceMode.Attribute)]
    > public virtual Interval MinuteInterval
    > {


    Remove
    DesignerSerializationVisibility(DesignerSerializationVisibility.Content).
    Default value for this attribute is Visible - it has to used set in
    your case.

    Regards,
    Mykola
    http://marss.co.ua
    marss, Jul 31, 2007
    #3
  4. marss Guest

    On 31 , 13:00, marss <> wrote:

    > it has to used set in your case.


    it has to be used in your case.
    marss, Jul 31, 2007
    #4
  5. Guest

    Removing
    DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
    fix the isssue.

    Thanks
    , Jul 31, 2007
    #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. -

    enum within an enum

    -, Jun 12, 2005, in forum: Java
    Replies:
    6
    Views:
    525
  2. Jerminia
    Replies:
    3
    Views:
    613
    Roedy Green
    Oct 7, 2005
  3. Ernst Murnleitner

    How to enum an enum?

    Ernst Murnleitner, Nov 12, 2003, in forum: C++
    Replies:
    5
    Views:
    443
    Rolf Magnus
    Nov 13, 2003
  4. mrhicks
    Replies:
    2
    Views:
    402
    Dave Thompson
    Jun 10, 2004
  5. Randy
    Replies:
    1
    Views:
    510
    David Harmon
    Jan 7, 2006
Loading...

Share This Page