Reputation: 2500
I've just started to create my website (from scratch with empty project) and I'm getting some errors however I'm really confused!
Default.aspx
<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="MonoLightTech.WebSite.Default" %>
<html>
<head>
<meta charset="utf-8" />
<title>MonoLight Technology</title>
</head>
<body>
<%= MonoLightTech.WebSite.Style.TestField %>
</body>
</html>
Style.cs (BuildAction: Compile)
namespace MonoLightTech.WebSite
{
public static class Style
{
public static string TestField = "MonoLight Technology";
}
}
Solution Hierarchy
Visual Studio: I also noticed, VS can see Style class and TestField member
I'm a C# programmer already (desktop) and I'm sure, there is no problem with member access. I also ReOpened the project, Cleaned the solution and ReBuilt the project. What's wrong? Should be simple I think :)
EDIT: Here is the solution project with all sources including all assets >>
Upvotes: 3
Views: 443
Reputation: 2500
Finally I see what's wrong. I've changed back Output path
from .\
to bin\
and it works. I really don't know why but this is the solution for me. Maybe someone can explain this later for us (I hope). And I think, starting from scratch not always the best way :)
Upvotes: 1
Reputation: 186
I can't tell if there are namespace issues with the page, but because you're namespacing Style.cs to the "MonoLightTech.Website" namespace explicitly, it may be that your Default.aspx only exists in the "MonoLightTech" namespace and so you'd need to drop an include statement at the top of the Default.aspx page like:
<%@ Import Namespace="MonoLightTech.Website" %>
In order to have access to the field in the Style class.
Upvotes: 0
Reputation: 738
Try to include following line at the top of the page:
<%@ Import Namespace="MonoLightTech.WebSite" %>
Upvotes: 0