Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 23rd, 2004, 11:53 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default table onClick

Hello,

I created a table dinamically with one image in every cell. I need to capture the event onClick and find the coordinates. How must I do?

Here are the code for my table:

                Panel1.Height = nColumnas * 15 + 2;
                for (int j=0; j<nFilas; j++)
                {
                    HtmlTableRow r = new HtmlTableRow();
                    r.BgColor="Gainsboro";
                    r.Height = "15";
                    row++;
                    for (int i=0; i<nColumnas; i++)
                    {
                        HtmlTableCell c = new HtmlTableCell();
                        HtmlInputImage image = new HtmlInputImage();
                        image.Src = "images/tapada.jpg";
                        c.Controls.Add(image);
                        c.Height = "15";
                        r.Cells.Add(c);
                    }
                    Table2.Rows.Add(r);
                    Table2.Align = "Center";
                }
                Table2.Width = Convert.ToString(nColumnas*15);

-------------------------------
World only exists into your mind.
 
Old January 23rd, 2004, 12:07 PM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am thinking about create an array of images and assign every image to the cells of the table. Then I will capture the event onClick from the htmlinputimage, because the table doesn't have this event.


-------------------------------
World only exists into your mind.
 
Old January 23rd, 2004, 04:44 PM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Buf... I think my idea was good, but I don't realize how to do it. How must I do to assign the property Src to one member of the array of htmlinputimages?

I created the array using the code:
Array imagen = Array.CreateInstance( typeof(HtmlInputImage), nFilas, nColumnas);

Usually, I use imagen.SetValue(number, nFila, nColumna)

But this code is for single types.


-------------------------------
World only exists into your mind.
 
Old January 23rd, 2004, 04:47 PM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

                        HtmlInputImage image = new HtmlInputImage();
                        image.Src = "images/tapada.jpg";
                        imagen.SetValue(image, j, i);

Could it be the code above the solution? It will work???

-------------------------------
World only exists into your mind.
 
Old January 23rd, 2004, 05:05 PM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, I think I've solved part of the problem:

                imagen = Array.CreateInstance( typeof(HtmlInputImage), nFilas, nColumnas);
                Panel1.Height = nColumnas * 15 + 2;
                for (int j=0; j<nFilas; j++)
                {
                    HtmlTableRow r = new HtmlTableRow();
                    r.BgColor="Gainsboro";
                    r.Height = "15";
                    for (int i=0; i<nColumnas; i++)
                    {
                        //c.Controls.Add(image);
                        HtmlTableCell c = new HtmlTableCell();
                        HtmlInputImage image = new HtmlInputImage();
                        image.Src = "images/tapada.jpg";
                        imagen.SetValue(image, j, i);
                        c.Controls.Add((HtmlInputImage)imagen.GetValue(j, i));
                        c.Height = "15";
                        r.Cells.Add(c);
                    }
                    Table2.Rows.Add(r);
                    Table2.Align = "Center";
                }
                Table2.Width = Convert.ToString(nColumnas*15);

Now, anybody could tell me how to capture the onclick event on every image, passing the coordinates?

Thanks to all!!! :)

-------------------------------
World only exists into your mind.





Similar Threads
Thread Thread Starter Forum Replies Last Post
onClick woes DennyLoi Javascript How-To 1 November 3rd, 2007 01:13 PM
onClick crmpicco Javascript How-To 1 March 21st, 2005 09:18 AM
onClick crmpicco HTML Code Clinic 2 February 24th, 2005 11:28 AM
How to use Onclick function for this jaya2109 BOOK: Beginning ASP 3.0 5 June 22nd, 2004 07:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.