web user control property values

Discussion in 'ASP .Net' started by Andy B, Dec 8, 2008.

  1. Andy B

    Andy B Guest

    I have a web user control that has a property called ViewMode. The property
    is an int and can be the values 1, 2 or 3 (the different view modes of the
    control). I have an enum defined called NewsViewMode that defines what 1, 2
    and 3 actually mean so I don't forget the values in code. What I need to do
    is be able to do something like ViewMode="Archive" instead of ViewMode=3.
    Makes it easier to remember a word than it does a number. How would I do
    this?
     
    Andy B, Dec 8, 2008
    #1
    1. Advertisements

  2. Just declare the property with the right type definition:

    public NewsViewMode ViewMode { get; set; }
     
    Joern Schou-Rode, Dec 8, 2008
    #2
    1. Advertisements

  3. Andy B

    Andy B Guest

    I needed to know how I would do ViewMode="archive" instead of ViewMode=1?
     
    Andy B, Dec 8, 2008
    #3
  4. Well, that is what I tried to answer as well. You simply need to declare
    the property with the right type (your custom enum type), and then you are
    able to declaratively assign it as ViewMode="Archive".
     
    Joern Schou-Rode, Dec 9, 2008
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.