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

  • Home
  • SEARCH
  • 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 9058361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:42:20+00:00 2026-06-16T14:42:20+00:00

In my program I used a dynamically button with below code: Button button =

  • 0

In my program I used a dynamically button with below code:

Button button = new Button();  
button.ID = counter.ToString();
button.Text = "ok";
button.Click += new EventHandler(this.ButtonClick);

list.Controls.Add(button);

And I have added click event’s code like below:

private void ButtonClick(object sender, EventArgs e)
{
    //..
}

There are several solutions:

C# Button Not Firing?

Dynamically created button not firing Click event

I have read and apply them but I cannot solve the problem.

My dynamic button operation is placed in Page_Load. (I tried it in Page_Init and it wasn’t fired again.)

In order to debug I use break point. I put it to the Page_Load, for the first time the page works and the program stops at the break point, and then I continue.. After I click the dynamic button, the code wasnot fired…

My Page_Load like below:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
         //..
         case "button":

         Button button = new Button();  
         button.ID = counter.ToString();
         button.Text = "ok";
         button.Click += new EventHandler(this.ButtonClick);


         list.Controls.Add(button);
         break;
    }
}
  • 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-06-16T14:42:22+00:00Added an answer on June 16, 2026 at 2:42 pm

    When you dynamically create controls in webforms, you need to recreate them dynamically AGAIN every postback.

    Make sure you learn the lifecycle for webforms pages, and reregister the controls BEFORE the event fires, during the pre-init phase.

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

Sidebar

Related Questions

My program looks like this! I want to have the bottom part dynamically load
In my Firefox extension, I create a popup menu dynamically. Originally, I used this
I am creating a program used to connect to a embedded bluetooth device with
I'm developing a controller program used to run a humanoid kidsize robot. The OS
I recently wrote a program that used a simple producer/consumer pattern. It initially had
I used to program for iPhone. But then I want to make another similar
I have a program that is used to create other program and compile it
Could UML be used to program a computer system on its own, without a
Under Windows, I have used a program called Dependency Walker to examine the libraries
I used SWIG to generate a Perl module for a C++ program. I have

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.