|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Declaring an Enum that the whole project can use?I've written an enumeration object, and now I want all the web forms
and web controls in my project to be able to use it. Is this possible? How can it be done? Thanks, -Dan Sure. Make it public and outside of all other classes. Maybe put it in its
own file or something. Why do you think you cannot? Show quote "danthman" <danth***@cox.net> wrote in message news:1134777001.919433.37600@o13g2000cwo.googlegroups.com... > I've written an enumeration object, and now I want all the web forms > and web controls in my project to be able to use it. Is this possible? > How can it be done? > > Thanks, > > -Dan > I put the following in the default.aspx.vb file before (i.e., outside)
the class definition: ----- Public Enum AccessModeEnum As Byte NoAcess SurveyAcess FullAcess End Enum ----- Then I attempted to refer to it in another aspx.vb module with: ----- If AccessModeByte = AccessModeEnum.NoAcess Then ,,, End If ----- And I get a squiggly line under AccessModeEnum with the error message: "AccessEnum is not declared" So, not to be a smart ass, but that's what makes me think I cannot :) Thx, -Dan Assuming you are using 2.0 you can put the following in your App_Code folder
inside of a .cs file: using System; public enum NobelGases { Helium, Neon, Argon, Krypton, Xenon, Radon } I think that technically the 'using System' is not required but it makes the code more readable in that you know where you are and most people look for a using section at the top of their file. Do the same with VB.NET but change where appropriate. Show quote "danthman" <danth***@cox.net> wrote in message news:1134777001.919433.37600@o13g2000cwo.googlegroups.com... > I've written an enumeration object, and now I want all the web forms > and web controls in my project to be able to use it. Is this possible? > How can it be done? > > Thanks, > > -Dan > you'd have to place it in a 3rd assembly that everything has a reference to
Show quote "danthman" wrote: > I've written an enumeration object, and now I want all the web forms > and web controls in my project to be able to use it. Is this possible? > How can it be done? > > Thanks, > > -Dan > > |
|||||||||||||||||||||||