Hi All,
Can someone please advise how I make controls on the page accessible
to class myClass, as defined below?
Any help will be appreciated!
Thank you.
Simon.
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Do stuff with controls - No problem...
lblMessage.Text = "Hello World";
}
}
public class myClass : System.Web.UI.Page
{
public myClass
{
}
public void setLabel
{
// This doesn't work...(Doesn't exist in the current
context)
lblMessage.Text = "Hello Again World!";
// Neither does this...(Null reference exception)
Label lblMess = new Label();
lblMess = (Label)FindControl("lblMessage");
lblMess.Text = "Hello Again World";
}
}