Controls within Custom Control Don't Render

Discussion in 'ASP .Net Web Controls' started by Demetri, Dec 5, 2003.

  1. Demetri

    Demetri Guest

    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);
    }
    Demetri, Dec 5, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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);
    > }
    Mark Fitzpatrick, Dec 5, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    715
  2. Boris Zakharin
    Replies:
    0
    Views:
    322
    Boris Zakharin
    Aug 6, 2003
  3. Replies:
    1
    Views:
    370
    Teemu Keiski
    Jul 2, 2003
  4. Matt Sokol
    Replies:
    2
    Views:
    374
    Theo Tillotson
    Aug 7, 2003
  5. Kenneth Baltrinic

    Accessing Server.MapPath from within Custom Controls Render() method?

    Kenneth Baltrinic, Oct 16, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    334
    Rajesh.V
    Oct 16, 2003
Loading...

Share This Page