473,396 Members | 1,853 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,396 software developers and data experts.

stuck with this simple code

I don't get it... so simple code but it's bringing an error which goes away
if I skip that <script Src="initialize.cs"> part...
("CS0038: Cannot access a nonstatic member of outer type
'System.Web.UI.Page' via nested type 'default_aspx.Initialize'")
PS it's running .Net 2.0 which explains the "ClassName" attribute in Page
directive
===default.aspx====
<%@ Page CompileWith="default.aspx.cs" ClassName="default_aspx" %>
<script Src="initialize.cs" runat="server"/>
<html>
<body>
<asp:Literal ID="LitBody" runat="server"/>
<asp:Literal ID="LitBody2" runat="server"/>
</body>
</html>

===initialize.cs===
public class Initialize
{
void Page_Load(object sender, System.EventArgs e)
{
LitBody2.Text = "Texti 2";
}
}
Nov 18 '05 #1
3 1821
the problem seems to be twofold

1) cannot access the Literal on the default.aspx page
2) if I include
using system;
....etc...

in top of my initialize.cs file a second error comes:
CS1519: Invalid token 'using' in class, struct, or interface member
declaration

I can't understand why it doesn't understand "using" in a c# file???
Nov 18 '05 #2
ok since I'm not getting any replies I'll try to figure out myself but I
suspect it's a scope issue so please can anyone tell me, is there some c#
syntax to tell me where in the scope my code is running?
Nov 18 '05 #3
Try this:

<%@ Page CompileWith="default.aspx.cs" ClassName="default_aspx" %>
<script language="C#" runat="server"/>
void Page_Load(object sender, System.EventArgs e)
{
LitBody2.Text = "Texti 2";
}
</script>
<html>
<body>
<asp:Literal ID="LitBody" runat="server"/>
<asp:Literal ID="LitBody2" runat="server"/>
</body>
</html>


"DavÃ*ð Þórisson" wrote:
I don't get it... so simple code but it's bringing an error which goes away
if I skip that <script Src="initialize.cs"> part...
("CS0038: Cannot access a nonstatic member of outer type
'System.Web.UI.Page' via nested type 'default_aspx.Initialize'")
PS it's running .Net 2.0 which explains the "ClassName" attribute in Page
directive
===default.aspx====
<%@ Page CompileWith="default.aspx.cs" ClassName="default_aspx" %>
<script Src="initialize.cs" runat="server"/>
<html>
<body>
<asp:Literal ID="LitBody" runat="server"/>
<asp:Literal ID="LitBody2" runat="server"/>
</body>
</html>

===initialize.cs===
public class Initialize
{
void Page_Load(object sender, System.EventArgs e)
{
LitBody2.Text = "Texti 2";
}
}

Nov 18 '05 #4

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

Similar topics

1
by: ron | last post by:
have been stuck on this for several days now. I am trying to create a reverse polish calculator and I'm stuck at an intermediate stage. This is what I know I have to do (just not sure how to do it...
8
by: Warren Post | last post by:
Here's a problem I've never seen before. On <http://snow.prohosting.com/srcopan/anti/>, should the viewport width be less than the width of the page's header, then the right margin becomes stuck...
3
by: Jeff Jarrell | last post by:
I have an object to execute a process. its intent is to do a simple execute and capture stdin and stdout. Nothing fancy, not for long processes. simple. I expect to typically use it with a fully...
0
by: Mark Phillips | last post by:
Hello, I am having a problem in which a file can get stuck open when a thread that is attempting to write to it gets aborted (ThreadAbortedException occurs). The log file gets stuck open until...
1
by: jessebasketball | last post by:
i am a very beginner programmer and am stuck on a very simple problem. I am trying to make a game where the user is presented with a scenerio and options. ie you are standing in the parking lot...
8
by: Alan Silver | last post by:
Hello, I'm trying to write a simple user control as an exercise (and 'cos it might be useful). I am trying to do a simple date picker, which consists of three drop down lists, one for the day,...
1
by: adriann | last post by:
Hi, I have a page that displays Mysql query results in either "simple" or "detailed" format. The directive to display in the desired format is obtained by looking at the value of a Session variable....
11
by: dave6502 | last post by:
Newbe C++ programmer. I am trying to bug fix a simple KDE application that uses C++. There is a main directory with .cpp & .h files in it. I need to write some additional code and split it up...
11
by: Peted | last post by:
Im using c# 2005 express edition Ive pretty much finished an winforms application and i need to significantly improve the visual appeal of the interface. Im totaly stuck on this and cant seem...
0
by: =?Utf-8?B?QmlsbEI=?= | last post by:
This is a tough one... My Windows Service app periodically performs some processing on new entries to a SQL Server database table. It uses a simple System.Timer to call the Elapsed event...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
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,...

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.