473,761 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Objec t 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(Objec t 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 1256
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*****@hotmai l.com> wrote in message
news:Xn******** *************** ********@140.99 .99.130...
I have the following in one of my .aspx pages:

....

<script runat="server">

enum bookstores

{
Amazon,
Blackwells,
ComputerManuals ,
ComputerBooks
};

void Page_Load(Objec t 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(Objec t 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*****@hotmai l.com> wrote in message
news:Xn******** *************** ********@140.99 .99.130...
I have the following in one of my .aspx pages:

....

<script runat="server">

enum bookstores

{
Amazon,
Blackwells,
ComputerManuals ,
ComputerBooks
};

void Page_Load(Objec t 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(Objec t 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
2078
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 and a chart (using dotnetCharting control) on the same page. This works just fine on its own. However, when I integrated the page into the rest of the site, it is then placed inside a frameset. Again, the page seems to work fine EXCEPT under the...
3
2005
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
1461
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
3163
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 Base64) with the host's dpapi using the entropy value(without storing it as Base64), and then store the encrypted Aes key value and the entropy value in some SHARED VARIABLES AS BYTE ARRAYS(not Base64). I then decrypt the stored encrypted Aes...
2
4554
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 set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
8
1993
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 do this? Like a foreach loop. Thanks for any help, CK
3
1311
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 searching the pages within the search scope, however, content pages that I have set up to use various masterpages are not being displayed properly (no doctitle). From what I've researched, this is because indexing service searches for content...
1
1127
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 have the the following events in my InitializeComponents section: this.Load += new System.EventHandler(this.Page_Load);
10
2203
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 has string value. I really do not understand why push_back() function is trying to remove previously inserted data. Thanks for any help
0
9336
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.