Whay's wrong with this javasript statement?

  • Thread starter Thread starter AAaron123
  • Start date Start date
A

AAaron123

In my javascript I have:
qq=document.getElementById("TextBox1")

The only way I know to debug javascript is with the debugger statement,
which I'm using.

QuickWatch shows a null for
document.getElementById("TextBox1")

In the debugger I scroll down and see that the HTML uses ctl00_TextBox1 for
the id so I try QuichWatch with

document.getElementById("ctl00_TextBox1")

And get the object description.

What am I doing wrong?


Thanks
 
Hi Aaraon,
AAaron123 said:
In my javascript I have:
qq=document.getElementById("TextBox1")
You have put TextBox1 in a container whose name is ctl00... So you have to
use ctl00_TextBox1...
You can check it by displaying the source of your page within your
navigator.

Oriane
 
Mark Rae said:
Not understanding how ASP.NET "munges" client-side DOM object names.
It was was obvious that it did that.
What I didn't know was how to get around it and the word "munges".
Next time I'm out to dinner I'm going to try to fit that word in!

Thanks a lot
 
Thanks for answering

Oriane said:
Hi Aaraon,

You have put TextBox1 in a container whose name is ctl00... So you have to
use ctl00_TextBox1...
You can check it by displaying the source of your page within your
navigator.

Oriane
 
I guess that was not my only problem.
I've been reading and still don't know if "Value" or "Text" is correct.
I tried both and they seen to work the same.
That is, after:
document.getElementById('<%=TextBox1.ClientID%>').Text= nar

debugger;

QuickWatch shows Value has the new string but the display does not show it.
Is changing the displayed text more complicated then what I did?


Thanks

PS Is debugger the best way to debug?
 
thanks for all the help

Mark Rae said:
That generates a JavaScript error for me - in fact, the only attribute
beginning with 't' which IntelliSense offers me is .tagName


Try using .value (note the lower-case) instead.


Nope - fairly standard stuff...


It's certainly the way I do it... Don't think it's supported by all
browsers, though - e.g. I believe FireFox needs an add-on:
https://addons.mozilla.org/en-US/firefox/addon/216
 
Back
Top