473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

problem putting enum in page_load

I have the following in one of my .aspx pages:

.....

<script runat="server">

enum bookstores

{
Amazon,
Blackwells,
ComputerManuals,
ComputerBooks
};

void Page_Load(Object sender, EventArgs e)

{
// DECLARE VARIABLES

.....

}

</script>
can someone tell me why the above works fine, yet if i put the enum
declaration IN Page_Load function above // DECLARE VARIABLES I get:
Compiler Error Message: CS1513: } expected

Line 10: void Page_Load(Object sender, EventArgs e)
Line 11:
Line 12: {
Line 13:
Line 14: enum bookstores
error on line 12 ?
Thanks to anyone who can throw light on this
Nov 18 '05 #1
2 1243
Enum is one value type in .NET (inherits from System.Enum). Types are
declared separately of their usage meaning you can consume / use the type
inside the method, but you declare it outside the method, just as class or
any other type would be. They are declared at namespace level and used as
class/member level.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*******************************@140.99.99.1 30...
I have the following in one of my .aspx pages:

....

<script runat="server">

enum bookstores

{
Amazon,
Blackwells,
ComputerManuals,
ComputerBooks
};

void Page_Load(Object sender, EventArgs e)

{
// DECLARE VARIABLES

....

}

</script>
can someone tell me why the above works fine, yet if i put the enum
declaration IN Page_Load function above // DECLARE VARIABLES I get:
Compiler Error Message: CS1513: } expected

Line 10: void Page_Load(Object sender, EventArgs e)
Line 11:
Line 12: {
Line 13:
Line 14: enum bookstores
error on line 12 ?
Thanks to anyone who can throw light on this

Nov 18 '05 #2
Enum is one value type in .NET (inherits from System.Enum). Types are
declared separately of their usage meaning you can consume / use the type
inside the method, but you declare it outside the method, just as class or
any other type would be. They are declared at namespace level and used as
class/member level.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*******************************@140.99.99.1 30...
I have the following in one of my .aspx pages:

....

<script runat="server">

enum bookstores

{
Amazon,
Blackwells,
ComputerManuals,
ComputerBooks
};

void Page_Load(Object sender, EventArgs e)

{
// DECLARE VARIABLES

....

}

</script>
can someone tell me why the above works fine, yet if i put the enum
declaration IN Page_Load function above // DECLARE VARIABLES I get:
Compiler Error Message: CS1513: } expected

Line 10: void Page_Load(Object sender, EventArgs e)
Line 11:
Line 12: {
Line 13:
Line 14: enum bookstores
error on line 12 ?
Thanks to anyone who can throw light on this

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bob N | last post by:
I have an ASP.NET web page -- several auto-post back DropDownLists that perform a query against a relatively large database (3 to 4 seconds delay) that repopulate a couple of datagrids, comboboxes...
3
by: M | last post by:
I can pass in a string to a Web User Control, but I haven't been successful passing in an enum. I declared my enum as a public variable in my Web User Control itself. Thanks in advance.
2
by: wapsiii | last post by:
I'm trying to do this http://geekswithblogs.net/jawad/archive/2005/06/24/EnumDropDown.aspx public enum Color { RED, GREEN, BLUE }
0
by: Phil C. | last post by:
(Cross post from framework.aspnet.security) Hi. I testing some asp.net code that generates a 256 bit Aes Symmetric Key and a 256 bit entropy value. I encrypt the Aes key(without storing it as...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
8
by: CK | last post by:
Hi All, Good morning. I had a quick question. I have a public Enum. During page load I want to loop thru the Enum and put those as items in an asp:dropdownList. Does anyone have any sample code to...
3
by: Chris Lincoln | last post by:
I am currently working on a company site and have run into a problem with the search aspect of the site. I am running .net 2.0 and iis 5.1. The issue is as follows: Indexing Service is properly...
1
by: tshad | last post by:
One of the differences with building one page style in DW and code behind in VS 2003 is you have to declare the events (apparently). For some reason my events will disapper. For example: I...
10
by: oktayarslan | last post by:
Hi all; I have a problem when inserting an element to a vector. All I want is reading some data from a file and putting them into a vector. But the program is crashing after pushing a data which...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.