Tuesday, March 13, 2012

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="http://pics.10026.com/?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====
<%@dotnet.itags.org. Page CompileWith="default.aspx.cs" ClassName="default_aspx" %>
<script src="http://pics.10026.com/?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";
}
}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?
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?
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*e T��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="http://pics.10026.com/?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="http://pics.10026.com/?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";
> }
> }
>

0 comments:

Post a Comment