I created a New Web Site
in Visual Studio 2008
, added a page with a control on it:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form runat="server">
<div>
<asp:Label runat="server" ID="lblFoobar">Foobar</asp:Label>
</div>
</form>
</body>
</html>
and generated code-behind class got a new field lblFoobar
.
I can access it into any member as a local instance variable. All works fine.
But when I created a New ASP.NET Application
the same approach throws an error:
The name 'lblFoobar' does not exist in the current context
Why?