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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:23:36+00:00 2026-06-10T09:23:36+00:00

I’ve implemented the clickable table cell using a extended class. However, when I call

  • 0

I’ve implemented the clickable table cell using a extended class. However, when I call the event handler/onclick method in my main class, the event handler doesn’t work.

Extended clickable table cell class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Member
{
    public class TableCellClick: TableCell, IPostBackEventHandler, INamingContainer
    {
        private static readonly object click_event = new object();

        // public handles for adding and removing functions to be called on the click event
        public event EventHandler Click
        {
            add
            {
                Events.AddHandler(click_event, value);
            }
            remove
            {
                Events.RemoveHandler(click_event, value);
            }
        }

        // define parent function that will be called when the container is clicked
        protected void OnClick(EventArgs e)
        {
            EventHandler h = Events[click_event] as EventHandler;
            if (h != null)
            {
                h(this, e);
            }
        }

        // specify the "post back event reference" or id of the click event
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, 
                                Page.ClientScript.GetPostBackEventReference(this, "custom_click"));
        }

        // link the custom click id to the click function
        void System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
        {
            if(eventArgument == "custom_click")
            {
                OnClick(EventArgs.Empty);
            }
        }
    }
}

The method in my Main class:

        memPanel.Visible = true;

        //Set a table width.
        memTable.Width = Unit.Percentage(40.00);
        //Create a new row for adding a table heading.
        TableRow tableHeading = new TableRow();

        //Create and add the cells that contain the msno column heading text.
        TableHeaderCell msnoHeading = new TableHeaderCell();
        msnoHeading.Text = "M'Ship No.";
        msnoHeading.HorizontalAlign = HorizontalAlign.Left;
        tableHeading.Cells.Add(msnoHeading);

        //Create and add the cells that contain the Name column heading text.
        TableHeaderCell nameHeading = new TableHeaderCell();
        nameHeading.Text = "Name";
        nameHeading.HorizontalAlign = HorizontalAlign.Left;
        tableHeading.Cells.Add(nameHeading);

        memTable.Rows.Add(tableHeading);

        while (reader.Read())
        {
            TableRow detailsRow = new TableRow();
            TableCellClick msnoCell = new TableCellClick();
            msnoCell.Text = reader["MSNo"].ToString();
            msnoCell.Click += cellClick;
            detailsRow.Cells.Add(msnoCell);

            TableCellClick nameCell = new TableCellClick();
            nameCell.Text = reader["fName"].ToString();
            nameCell.Click += cellClick;

            memTable.Rows.Add(detailsRow);

        }

The onclick method:

protected void cellClick(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("cell click");
    memPanel.Visible = false;
    basicInfo.Visible = true;
}

Anyone knows where it went wrong?

  • 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-10T09:23:37+00:00Added an answer on June 10, 2026 at 9:23 am

    The reason why it wasn’t called is because of the postback method every time a button is clicked.
    My cell wasn’t created in the pageload method that’s why it didn’t get called when the cell button is clicked.

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to

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.