Your aspx:
<asp:Label id="lblTest" Runat="server"></asp:Label>
Your C#:
using System;
......
using System.Web.UI.WebControls;
namespace SomeSpace
{
public class MyPage : SomeNamespace.BaseClassName
{
protected Label lblTest;
private void Page_Load(...)
{
lblTest.Text = "Some Text";
}
}
}
Compile it and it'll work. Your C# "code-behind" class is the base class for
your aspx html page. Therefore, you have to declare your control in C# class
and since you're not going to use it in any other class make it "protected"
(not "private" or "public") so it'll be visible to your aspx page.
Regards,
Kikoz
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:F8**********************************@microsof t.com...
Hi, i am using code behind c# pages. I have put a couple of asp:labels on
the
aspx html page. in the code behind i am trying to set them programatically
but am getting error
The type or namespace name 'mylabel' could not be found (are you missing a
using directive or an assembly reference?)
and it has a wiggly line under it. I have saved the aspx file, but cant
get
the .cs file to recognise it. What comes first? Or what am I missing? I
have
got
using System.Web.UI.WebControls;
at the top of my cs file.
using