Composite Server Controls Question

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
 
T

Teemu Keiski

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.
 
J

John Saunders

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top