Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 323347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:01:22+00:00 2026-05-12T09:01:22+00:00

I have a Control I want to create. Here’s a simple example of what

  • 0

I have a Control I want to create. Here’s a simple example of what I was to accomplish.

I want the control to contain a button.

Button b = new Button();
b.Text = "Test";
b.Click += new EventHandler(b_Click);

this.Controls.Add(b);

Now, the control renders fine, the button shows up on the page. The heart of the problem I’m having is that the b_Click Event Handler is never triggered.

protected void b_Click(object sender, EventArgs e)
{
    throw new NotImplementedException();
}

Any help here would be much appreciated. I don’t want to use a User Control here for purely selfish reasons and would like to totally encapsulate this in a single DLL.

Thanks In Advance.

EDIT**

namespace ClassLibrary1
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
    public class WebCustomControl1 : WebControl
    {

        protected override void CreateChildControls()
        {
            Button b = new Button();
                    b.ID = "button";
            b.Text = "Click Me";
            b.Click += new EventHandler(b_Click);

            this.Controls.Add(b);

            base.CreateChildControls();
        }

        protected void b_Click(object sender, EventArgs e)
        {
            this.Controls.Add(new LiteralControl("<p>Click!</p>"));
        }

    }
}

So from the comments I’ve tried this. The simplest of exampes, still no go. Is there something I’m fundamentally missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:01:22+00:00Added an answer on May 12, 2026 at 9:01 am
    public class WebCustomControl1 : WebControl
    

    needed to be

    public class WebCustomControl1 : WebControl, INamingContainer
    

    that’s it. that’s all that was needed to make this postback issue work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a datagrid in a control(here:DataGridSelectorControl) and i want to create it's coulmns
I want a create a custom/user control that has children. For Example, I want
I have created a Dynamic View Panel custom control and want to add a
I have created the DateTimePicker control. Now i want to add localization Support with
I want to read UTF-8 strings from a server that I have control of,
I really want to have full control of section headers by laying out in
I have a tree control and I want to give the user the ability
I have a custom control and I want to dynamically insert a link to
I have asp:DropDownList control which i want to display data to user who don't
I have a 3rd party ActiveX control I want to render within other presentation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.