Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Bitwise Enum problem in Custom Control

Bitwise Enum problem in Custom Control

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netvisual-studiodata-structures
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Donald_a
    wrote on last edited by
    #1

    I have a web custom control with the following property:

    private AvailablePages _LinksToDisplay = AvailablePages.Home;
    
    public AvailablePages LinksToDisplay 
    {
            get{return this._LinksToDisplay;}
    	set{this._LinksToDisplay = value;}
    }
    

    AvailablePages is an enum with the flags attribute set:

    [Flags()]
    public enum AvailablePages : int
    {
    	Home = 1,
    	AddNewCCRate = 2,
    	AddNewCCRateValue = 4,
    	AmendCCRateValue = 8,
    	AddNewForecastRate = 16,
    	AddNewForecastRateValue = 32,
    	AmendForecastRateValue = 64,
    	AddNewRate = 128,
    	AddNewRateValue = 256,
    	AmmendRateValue = 512
    }
    

    This works if only one enumeration is chosen through visual studio's web forms designer. Code is written to the control's tag on the .aspx page along the lines of: LinksToDisplay="Home" However, when multiple values are chosen, the designer writes something like: LinksToDisplay="Home,AmendCCRateValue" and the page throws an "Object reference not set to an instance of an object" error before any code is run (EG can't get it to stop at a break point before it fails). The stack trace starts:

    [NullReferenceException: Object reference not set to an instance of an object.]
       System.Web.Compilation.CodeDomUtility.GenerateExpressionForValue(PropertyInfo propertyInfo, Object value, Type valueType)
    

    I think this is a problem with the conversion from the comma seperated string to a bitwise enum, but have had no luck looking for a way around it. Any help will be much appreciated.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups