473,395 Members | 2,446 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,395 software developers and data experts.

nebie problem with c# asp.net syntax....

DC
Why in the hell am i getting this error?

Compiler Error Message: CS1519: Invalid token 'using' in class,
struct, or interface member declaration

Source Error:

Line 5: <script runat="server">
Line 6:
Line 7: using System;
Line 8: using System.Collections;
Line 9: using System.IO;

The code isnt really importanat but try as I might the "using" keyword
is causing an error, is this common am I being incredbly stupid? Does
anyone have a good example of a very basic c# asp.net pagI can play with?

Never had this much hassle writing scripts in vbscript :)

Thanks in advance.

--
_______________________________________________

DC

"You can not reason a man out of a position he did not reach through reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law

Nov 19 '05 #1
2 1050
The problem is that code in the <script runat=server> goes in the class definition,
so:

<script runat=server>
void foo() {}
</script>

becomes

class YourPage : Page {
void foo() {}
....
}

So when you put the using starements in there it becomes:
class YourPage : Page {
using System;
void foo() {}
....
}

Which is illegal. You need the <%@ Import %> directive instead at the top
of the page:
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.Collections"%>
etc...

-Brock
DevelopMentor
http://staff.develop.com/ballen
Why in the hell am i getting this error?

Compiler Error Message: CS1519: Invalid token 'using' in class,
struct, or interface member declaration

Source Error:

Line 5: <script runat="server">
Line 6:
Line 7: using System;
Line 8: using System.Collections;
Line 9: using System.IO;
The code isnt really importanat but try as I might the "using" keyword
is causing an error, is this common am I being incredbly stupid? Does
anyone have a good example of a very basic c# asp.net pagI can play
with?

Never had this much hassle writing scripts in vbscript :)

Thanks in advance.

DC

"You can not reason a man out of a position he did not reach through
reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law



Nov 19 '05 #2
DC
Cheers thats really helpful. Seems liek none of the examples ou there
are really designed to explain how to do things for a total newbie. They
all seem to be about principles rather than practicality.

Anyway thanks again,

Brock Allen wrote:
The problem is that code in the <script runat=server> goes in the class
definition, so:

<script runat=server>
void foo() {}
</script>

becomes
class YourPage : Page {
void foo() {}
...
}

So when you put the using starements in there it becomes:
class YourPage : Page {
using System;
void foo() {}
...
}

Which is illegal. You need the <%@ Import %> directive instead at the
top of the page:
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.Collections"%>
etc...

-Brock
DevelopMentor
http://staff.develop.com/ballen
Why in the hell am i getting this error?

Compiler Error Message: CS1519: Invalid token 'using' in class,
struct, or interface member declaration

Source Error:

Line 5: <script runat="server">
Line 6:
Line 7: using System;
Line 8: using System.Collections;
Line 9: using System.IO;
The code isnt really importanat but try as I might the "using" keyword
is causing an error, is this common am I being incredbly stupid? Does
anyone have a good example of a very basic c# asp.net pagI can play
with?

Never had this much hassle writing scripts in vbscript :)

Thanks in advance.

DC

"You can not reason a man out of a position he did not reach through
reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law



--
_______________________________________________

DC

"You can not reason a man out of a position he did not reach through reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law

Nov 19 '05 #3

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

Similar topics

68
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
3
by: Prophet | last post by:
Hi, I have a new web page and it is posted on yahoo. I would like to make it so that a person can do a search and find my pace. How do I do this???
6
by: Daniel Rudy | last post by:
What is wrong with this program? When I try to compile it, I get the following error. Compiler is gcc on FreeBSD. strata:/home/dcrudy/c 1055 $$$ ->cc -g -oe6-3 e6-3.c e6-3.c: In function...
1
by: darren | last post by:
Hi whell with alot of help from websites and the peoiple on this group i have just about finished my small program i just have one question i have include a com component " windows script Host...
2
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before...
1
by: K.K. | last post by:
Hi all, I'm wondering is it possible to retrieve (or save) data from database and display it in a calender format? If it can be done can you post a sample code or point me to some web site with...
10
by: Protoman | last post by:
Could you tell me what's wrong with this program, it doesn't compile: #include <iostream> #include <cstdlib> using namespace std; class Everything { public: static Everything* Instance()
13
by: Dave Schwimmer | last post by:
Is it possible to 'hide' javascript from a user. I am thinking of putting some fairly proprietary logic client side (to release burden on server) - but I dont want to make the source freely...
1
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.