473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Adding events to TableCells

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
Nov 20 '05 #1
5 8475
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" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:O2**************@TK2MSFTNGP14.phx.gbl...
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

Nov 20 '05 #2
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" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:O2**************@TK2MSFTNGP14.phx.gbl...
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

Nov 20 '05 #3
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
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?
Nov 20 '05 #4
This URL shows you how to force a postback to occur on a page.

http://weblogs.asp.net/mnolton/archi...6/04/8260.aspx

http://www.mredkj.com/vbnet/textboxt...dpostback.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" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:O2**************@TK2MSFTNGP14.phx.gbl...
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

Nov 20 '05 #5
"S.M. Altaf [MVP]" <sm*****@PLEASEDONTSPAMMEmsn.com> wrote in message
news:Oq**************@TK2MSFTNGP11.phx.gbl...
This URL shows you how to force a postback to occur on a page.

http://weblogs.asp.net/mnolton/archi...6/04/8260.aspx

http://www.mredkj.com/vbnet/textboxt...dpostback.html

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


Perfect! Thanks... :-)
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sue | last post by:
On code-behind page: (attributes set programatically for each of these elements) linkbutton added to tablecell textbox added to tablecell tablecells added to tablerow tablerow added to table...
4
by: Lloyd Sheen | last post by:
Perhaps I am missing something or it does not exist. I am used to VB.NET and when you have a windows form you can easily create a handler using the drop down list. This does not seem to exist in...
2
by: JezB | last post by:
I'm adding WebControl objects to a Page dynamically on Page_Load, but I'm having trouble attaching events to these. For example, adding an image button :- ImageButton nb = new ImageButton();...
3
by: Shawn | last post by:
Hi. I have an asp:table, like this: <asp:Table runat="server" id="Table1"> <asp:TableRow Runat="server"> <asp:TableCell id="tc1" Runat="server">&nbsp;</asp:TableCell> <asp:TableCell id="tc2"...
4
by: Dinsdale | last post by:
I'm looking at adding scheduling features to an application and I wanted to ask the community about any experience with scheduling components, either open source like from code project or from a...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
4
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I will have a fixed number of columns in a tablecell array, but the number rows will be dynamic. Is there a way to add array items at run time? -- (i''ll be asking a lot of these, but I find C#...
3
by: raylopez99 | last post by:
Oh, I know, I should have provided complete code in console mode form. But for the rest of you (sorry Jon, just kidding) I have an example of why, once again, you must pick the correct entry point...
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.