Composite Server Controls Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a composite control containing a TextBox. The Text property just delegates to the TextBox.Text property. EnsureChildControls() is the first thing I call in both the Get and Set operations.
Nevertheless, whenever I change the value of the Text property at design time I get the "Object reference not set to an instance of an object." error.
I assume the child TextBox is not created and so it cannot be found.
Am I correct and if yes, why?
EnsureChildControls() shouldn't have been taking care of that?

Any ideas?
dimitris
 
Hi,

is the the child TextBox accessed properly...e.g it is reference to TextBox
which is created in CreateChildControls?

Can you post the relevant code?

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


Dimitris Pantazopoulos said:
I created a composite control containing a TextBox. The Text property
just delegates to the TextBox.Text property. EnsureChildControls() is the
first thing I call in both the Get and Set operations.
Nevertheless, whenever I change the value of the Text property at design
time I get the "Object reference not set to an instance of an object."
error.
 
Dimitris Pantazopoulos said:
I created a composite control containing a TextBox. The Text property
just delegates to the TextBox.Text property. EnsureChildControls() is the
first thing I call in both the Get and Set operations.
Nevertheless, whenever I change the value of the Text property at design
time I get the "Object reference not set to an instance of an object."
error.
I assume the child TextBox is not created and so it cannot be found.
Am I correct and if yes, why?
EnsureChildControls() shouldn't have been taking care of that?

EnsureChildControls works by calling your CreateChildControls override.
That's where you should create the child TextBox.
 
Back
Top