Controls within Custom Control Don't Render

D

Demetri

I have created a control library project and a web test project within the same solution. I have followed the walkthrough that MSDN provides on how to create a custom control. All works well.

However, I attempt to create an ASP.Net TextBox control on the custom control and it does not render on the web page when I run the web project.

Here is my code on the custom controls class, Its an override function that adds the controls to the custom control. When I put a break point in there it does indeed stop on it thus I know the event is firing. When the form finishes building these controls do not appear on the page. What am I doing wrong???

protected override void CreateChildControls()
{
this.myTextBox.Text = string.Empty;
this.myGetLinkButton.Text = "Get";
this.myResetLinkButton.Text = "Reset";

Controls.Add(this.myTextBox);
Controls.Add(this.myGetLinkButton);
Controls.Add(this.myResetLinkButton);
}
 
M

Mark Fitzpatrick

You aren't calling the base method, which could be part of it. Try adding

base.CreateChildControls ();

as the last line (or you may try it at the first line) of your overridden
createchildcontrols method.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

Demetri said:
I have created a control library project and a web test project within the
same solution. I have followed the walkthrough that MSDN provides on how to
create a custom control. All works well.
However, I attempt to create an ASP.Net TextBox control on the custom
control and it does not render on the web page when I run the web project.
Here is my code on the custom controls class, Its an override function
that adds the controls to the custom control. When I put a break point in
there it does indeed stop on it thus I know the event is firing. When the
form finishes building these controls do not appear on the page. What am I
doing wrong???
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top