share enum between pages?

O

oaksong

I've got an enum in a code behind page. It's set as public enum. How
do I access it from another page?

tia
Chris
 
N

Nathan Sokalski

The same way as you would anything else that you want to access from other
pages. Just make sure it is not declared as part of the class for the page,
it can be easy to accidentally make an enum part of the page when you don't
want to. Or if you would like you can simply stick it in a separate file,
this might help you keep it organized as not being part of the codebehind.
 
B

bruce barker

this is a bad practice. pages should not access each other. the proper
way is to move the enum to a class file in the app code folder.

-- bruce (sqlwork.com)
 
O

oaksong

this is a bad practice. pages should not access each other. the proper
way is to move the enum to a class file in the app code folder.

-- bruce (sqlwork.com)

I have a class file in the app code folder. I put the enum into that
file. When I tried to reference it from a codebehind page it produced
an error.
 
N

Norm

I have a class file in the app code folder. I put the enum into that
file. When I tried to reference it from a codebehind page it produced
an error.

What was the error? (nobody can help you if you just say "an error")
 
O

oaksong

What was the error? (nobody can help you if you just say "an error")- Hide quoted text -

- Show quoted text -

The enum is named 'cpage'.
The error is: error BC30451: Name 'cPage' is not declared.
 
N

Norm

The enum is named 'cpage'.
The error is: error BC30451: Name 'cPage' is not declared.

The error means (I'm pretty sure) that the enum is not in scope.
Without code, It's hard to diagnose. Here are some tips:

1. Is the enum inside of a class and/or namespace?
1.1 If in a class, is it declared "Public"?
1.2 If in a namespace, is the namespace imported in the page that you
are attempting to access it?

Note: If you do end up finding the problem, make sure you post it so
other people know the fix.
 
H

Hans Kesting

oaksong wrote :
The enum is named 'cpage'.
The error is: error BC30451: Name 'cPage' is not declared.

Are you using C#? That is case-sensitive, so "cpage" and "cPage" are
different things.

Hans Kesting
 
O

oaksong

The error means (I'm pretty sure) that the enum is not in scope.
Without code, It's hard to diagnose. Here are some tips:

1. Is the enum inside of a class and/or namespace?
1.1 If in a class, is it declared "Public"?
1.2 If in a namespace, is the namespace imported in the page that you
are attempting to access it?

Note: If you do end up finding the problem, make sure you post it so
other people know the fix.

The reference was out of scope. I needed to import my enums class.
Thanks!
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top