Adding events to TableCells

Discussion in 'ASP .Net' started by Mark Rae, Nov 17, 2005.

  1. Mark Rae

    Mark Rae Guest

    Hi,

    Is it possible to add events, specifically a Click event, to a dynamically
    created TableCell?

    I have an <asp:Table...> control to which I'm dynamically adding TableRow
    controls made up of TableCell controls - before you ask, the underlying data
    is really not suitable for a DataGrid or Repeater...

    Now, the client is asking for each dynamically added TableCell control to
    respond to a server-side Click event - is this possible?

    Mark
     
    Mark Rae, Nov 17, 2005
    #1
    1. Advertising

  2. Sort of, yes. The problem is not adding the event to a table cell; it is
    adding the event to a TableCell object instance. Since you're using a Table
    WebControl, this event is not part of the object model. It *is* part of the
    HTML Document Object Model supported by all (at least that I know of)
    browsers.

    So, what you need to do is to create a class that inherits TableCell, and
    define a server click event for it. Then use that in your Table Control.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    If you push something hard enough,
    it will fall over.
    - Fudd's First Law of Opposition


    "Mark Rae" <> wrote in message
    news:...
    > Hi,
    >
    > Is it possible to add events, specifically a Click event, to a dynamically
    > created TableCell?
    >
    > I have an <asp:Table...> control to which I'm dynamically adding TableRow
    > controls made up of TableCell controls - before you ask, the underlying
    > data is really not suitable for a DataGrid or Repeater...
    >
    > Now, the client is asking for each dynamically added TableCell control to
    > respond to a server-side Click event - is this possible?
    >
    > Mark
    >
     
    Kevin Spencer, Nov 17, 2005
    #2
    1. Advertising

  3. Mark,

    TableCell doesn't support server-side onclick event (at least it is not
    listed). What about adding a client-side onclick event that will submit the
    page?

    Eliyahu

    "Mark Rae" <> wrote in message
    news:...
    > Hi,
    >
    > Is it possible to add events, specifically a Click event, to a dynamically
    > created TableCell?
    >
    > I have an <asp:Table...> control to which I'm dynamically adding TableRow
    > controls made up of TableCell controls - before you ask, the underlying
    > data is really not suitable for a DataGrid or Repeater...
    >
    > Now, the client is asking for each dynamically added TableCell control to
    > respond to a server-side Click event - is this possible?
    >
    > Mark
    >
     
    Eliyahu Goldin, Nov 17, 2005
    #3
  4. Mark Rae

    Mark Rae Guest

    "Eliyahu Goldin" <> wrote in message
    news:...

    > TableCell doesn't support server-side onclick event (at least it is not
    > listed). What about adding a client-side onclick event that will submit
    > the page?


    Yes, but will I be able to wire the postback up server-side?
     
    Mark Rae, Nov 17, 2005
    #4
  5. This URL shows you how to force a postback to occur on a page.

    http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx

    http://www.mredkj.com/vbnet/textboxtextchangedpostback.html

    You can modify the code for your purpose by adding an attribute for onClick
    to your table cell.

    HTH
    Altaf
    --------------------------------------------------------------------------------
    All that glitters has a high refractive index.
    www.mendhak.com


    "Mark Rae" <> wrote in message
    news:...
    > Hi,
    >
    > Is it possible to add events, specifically a Click event, to a dynamically
    > created TableCell?
    >
    > I have an <asp:Table...> control to which I'm dynamically adding TableRow
    > controls made up of TableCell controls - before you ask, the underlying
    > data is really not suitable for a DataGrid or Repeater...
    >
    > Now, the client is asking for each dynamically added TableCell control to
    > respond to a server-side Click event - is this possible?
    >
    > Mark
    >
     
    S.M. Altaf [MVP], Nov 17, 2005
    #5
  6. Mark Rae

    Mark Rae Guest

    Mark Rae, Nov 17, 2005
    #6
    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. Diane Yocom

    Extra space after asp:tablecells?

    Diane Yocom, Apr 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    406
    Diane Yocom
    Apr 15, 2004
  2. gane kol

    Building Dynamic tablecells

    gane kol, Mar 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    353
    Lars Netzel
    Mar 17, 2005
  3. Hugo de Payns
    Replies:
    5
    Views:
    513
    Leif K-Brooks
    Oct 2, 2003
  4. SevDer
    Replies:
    2
    Views:
    1,304
    Walter Wang [MSFT]
    Nov 13, 2007
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    373
    Chris
    Aug 30, 2005
Loading...

Share This Page