This one should be pretty simple. I am making a non-MVC ASP.NET 2.0 site. VS2008 seems to generate controls with a <script>
area -- I want the code in a codebehind, so I've manually hooked that up.
I have the following:
widget.ascx:
<%@ Control Language="C#" ClassName="widget" Codebehind="widget.ascx.cs" Inherits="widget"%>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
widget.ascx.cs:
namespace webapp
{
public partial class widget : System.Web.UI.Control
{
protected void Page_Load(object sender)
{
Label1.Text = Session["user_id"].ToString();
}
}
}
I copy and pasted this stuff from ASPX pages that use codebehind files, but when I try to compile I get errors that Label1 does not exist in this context
.
All help in the matter appreciated.