Please forgive the psuedo-code, but it's a simple question:
I create a user control (myControlBase : UserControl) with a textbox (id = "txtbox") in it's markup. In it's codebehind I write a method SayHello(string s){ txtbox.Text = s; }.
I create another user control that extends myControlBase (myControl : myControlBase). In page_load of this child control, I call SayHello("hello"); and receive a runtime error telling me that txtbox is null (it hasn't been created yet obviously).
How then, can I inherit from a user control and have my child controls access the base control's markup? I've tried to read up on event lifecycle for these controls, but I guess I'm not getting it.
Any ideas?
-edit-
I'm sorry, it is ASP.Net. If this code makes it any clearer, then I must have done a pretty poor job of describing the issue.
txtBox is an ASP:Textbox Control that exists in the markup of myControlBase.
public partial class myControlBase : System.Web.UI.UserControl
{
protected void SayHello(string s){
txtBox.Text = s;
}
}
public partial class myControl: myControlBase
{
protected void Page_Load(object sender, EventArgs e)
{
SayHello("hello");
}
}
This would fail at SayHello("hello"); because txtBox returned Null.