Whay's wrong with this javasript statement?

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
 
O

Oriane

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
 
A

AAaron123

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
 
A

AAaron123

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
 
A

AAaron123

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?
 
A

AAaron123

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top