Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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 June 15th, 2006, 12:05 PM
Friend of Wrox
Join Date: Apr 2006
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to get ID of server-control in Javascript?


In the aspx file, i create a table:
<asp:Table ID="table1" runat="server">

In the code-behind, i define a lot of cells with each an unique ID and some of them a background color (red):
Dim r As TableRow
Dim c(x,y) As TableCell
For i = 0 To x
r = New TableRow()
For j = 0 To y
c(i, j) = New TableCell()
c(i, j).ID = j & ":" & i.ToString
c(i,0).BackColor = System.Drawing.ColorTranslator.FromHtml("red")
r.Cells.Add(c(i, j))

The purpose is: when the user clicks in the table, the backgroundclor of the cell must be rendered which can generate some other action.
I did this in Javascript: (i want here the color of cell "2:2")
<script language="javascript" type="text/javascript">
function tableclick(event)
document.getElementById("table1").onclick = tableclick

But the alert gives always an empty window (no error).
Thanks for any help.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting id of a control in javascript sudhir164 Javascript How-To 2 February 23rd, 2008 05:35 AM
Passing asp control id to javascript jazzcatone ASP.NET 1.0 and 1.1 Professional 0 October 18th, 2006 01:38 PM
Master pages &server control ID - asp.net 2.0 tech user C# 2005 1 August 3rd, 2006 04:31 AM
using javascript for server control validation swagatika ASP.NET 1.0 and 1.1 Basics 3 December 20th, 2005 08:38 AM

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