|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
can get forecolor but not background color in JavascriptWhen clicked into any cell of the table, i want to get the background color of it. I can get the forecolor but not the bakground color (gives an empty Alert, no error). I think i can't change anything in the code-behind, so the error will be in the javascript code ... Thanks for your help Bob the aspx file: ----------- <asp:Table ID="table1" runat="server"> </asp:Table> <script language="javascript" type="text/javascript"> function tableclick(event) { forecl=window.event.srcElement.style.color // this works backcl=window.event.srcElement.style.background // this not alert(forecl) alert(backcl)} } the code-behind: ---------------- 'creattion of the cells in the table Dim r As TableRow Dim c(50, 20) As TableCell For i = 0 To 50 r = New TableRow() For j = 0 To 20 c(i, j) = New TableCell() r.Cells.Add(c(i, j)) Next Table1.Rows.Add(r) Next .... //e.g. the back/forecolor of cell 3,2: c(3, 2).BackColor = System.Drawing.ColorTranslator.FromHtml("red") c(3, 2).ForeColor = System.Drawing.ColorTranslator.FromHtml("yellow") //c(3, 2).BackColor = Drawing.Color.Red // tried also with this method .... "Bob" <s**@sdvsd.dc> wrote in It's not possible to read the default style properties of a DOM element. news:udHT3xekGHA.1204@TK2MSFTNGP02.phx.gbl: > When clicked into any cell of the table, i want to get the background > color of it. I can get the forecolor but not the bakground color > (gives an empty Alert, no error). > I think i can't change anything in the code-behind, so the error will > be in the javascript code ... They'll always return 'undefined' or whatever passes for that in JavaScript. Thanks, but then, how do you explain it works with the forecolor?
There must be a way to do the same with the background ... Show quoteHide quote "Klaus H. Probst" <usenet***@simulplex.net> wrote in message news:Xns97E519D47DEE945F9BC4070F84482B8A8@207.46.248.16... > "Bob" <s**@sdvsd.dc> wrote in > news:udHT3xekGHA.1204@TK2MSFTNGP02.phx.gbl: > > > When clicked into any cell of the table, i want to get the background > > color of it. I can get the forecolor but not the bakground color > > (gives an empty Alert, no error). > > I think i can't change anything in the code-behind, so the error will > > be in the javascript code ... > > It's not possible to read the default style properties of a DOM element. > They'll always return 'undefined' or whatever passes for that in > JavaScript. > > > -- > Klaus H. Probst, MVP > http://www.simulplex.net/ > Bob said the following on 6/17/2006 4:59 AM:
> Hi, <snip>> > When clicked into any cell of the table, i want to get the background color > of it. I can get the forecolor but not the bakground color (gives an empty > Alert, no error). > I think i can't change anything in the code-behind, so the error will be in > the javascript code ... > backcl=window.event.srcElement.style.background // window.event.srcElement.style.backgroundColor;-- Randy comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ thanks
Show quoteHide quote "Randy Webb" <HikksNotAtH***@aol.com> wrote in message http://www.JavascriptToolbox.com/bestpractices/news:DJudnXT4kNAPdQ7ZnZ2dnUVZ_qSdnZ2d@comcast.com... > Bob said the following on 6/17/2006 4:59 AM: > > Hi, > > > > When clicked into any cell of the table, i want to get the background color > > of it. I can get the forecolor but not the bakground color (gives an empty > > Alert, no error). > > I think i can't change anything in the code-behind, so the error will be in > > the javascript code ... > > <snip> > > > backcl=window.event.srcElement.style.background // > > window.event.srcElement.style.backgroundColor; > > -- > Randy > comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly > Javascript Best Practices -
how to get the text in JS of a cell created on server?
why does this not work? Retrieving Asp.treeview checked checkbox information Uploading to a folder outside the www ... ? questions about Controls.add HyperLink control vs. Firefox FormView/Repeater/ Eval(FormView data) ASP.Menu in IE6, cannot select menu item when... multiple datagrids on same page paging broken FormView - set mode in aspx based on url param |
|||||||||||||||||||||||