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 8647503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:05:21+00:00 2026-06-12T13:05:21+00:00

If I create ImageButton dynamically and add this into table cell TableRow tr =

  • 0

If I create ImageButton dynamically and add this into table cell

TableRow tr = new TableRow();
TableCell tc = new TableCell();
ImageButton imagebutton= new ImageButton();
imagebutton.imageurl=imageurl;
imagebutton.click+= new System.Web.UI.ImageClickEventHandler(click);
tc.Controls.Add(imagebutton);
tr.Controls.Add(tc);
Table1.Rows.Add(tr);

The click event doesnt’ work.

However, if I use Panel instead of table the imagebutton works. Morevoer If I add imagebutton to the page directly it also works.
But I need store imagebutton in a table cell.

What is a problem?
How to make working imagebutton inside asp table?

The method click is:

protected void click(object sender, EventArgs e)
{
      Response.Write("<script type='text/javascript'>alert('OK!');</script>"); 
}
  • 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-12T13:05:22+00:00Added an answer on June 12, 2026 at 1:05 pm

    What is a problem?

    This seems to be a classic asp.net page life-cycle problem. It’s cause is probably that, a the time the click should be handled, your button, as well as your table, do not exist because you create it later in the page life cycle (say in pre_render), or you only create when not on postback, or in another control event handler.

    How to make working imagebutton inside asp table?

    Your table and button creation , as well as click handler binding should be located in

    page_load (even better, in Init, when using view_state for dynamic controls)

    The code should run whether on postback or not.

    Hope this will help

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

Sidebar

Related Questions

Create IMageButton and add to toolstrip: ImageButton imageButton1 = new ImageButton(); toolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
CREATE TABLE #TEMPTABLE ( requestTime datetime2, NoOfSessions integer ) INSERT INTO #TEMPTABLE select convert(nvarchar(16),
create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
I have this image for imagebutton, and i need to create patch 9 of
I'm trying to dynamically and programmatically create ImageButtons and add them to my Scrolling
I am trying to create an add to 'favourites'button. When the user clicks this
On Page_Init I create a table of dynamically created controls based on a couple
I am dynamically creating a table of ImageButton, I would like to have setPressed
I am learning ASP.Net. I have a dynamically created ImageButton that I would like
CREATE TABLE `tbl_atn` ( `atn_id` int(15) NOT NULL AUTO_INCREMENT, `eng_id` int(15) DEFAULT NULL, `visit`

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.