still not working

  • Thread starter Charles A. Lackman
  • Start date
C

Charles A. Lackman

How do I retrieve a value from an ASP.NET Textbox in Java Script.

The following code returns Null, What am I doing wrong?

var AName = document.GetElementById("txtName.Value")

Changing "Value" to "Text" also returns Null, Also, if I remove "Value"
[object] is returned.

txtName is a ASPX textbox that the visitor places their name into.

Thanks
Chuck
 
V

Vidar Petursson

Hi

var v = document.forms["FORMNAME"].FIELDNAME.value;

Or if using getElementById.... ( document.forms... is better if supporting
older browsers)
document.getElementById("ELEMENTID");
CaseSensitive... ( NOT GetElementById )

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
 
D

David Waz...

You cannot use the ASPX name of the control.
Instead, you need to use a modified version of the
controls ".UniqueID" property....

javaName = replace(txtName.UniqueID,":","_")
and use that name in your script.

Email if you need more.
 
K

Karl Seguin

not 100% sure, but don't you want ClientID which unlike UniqueID, doesn't
contain illegal javascript variable characters.

Karl

David Waz... said:
You cannot use the ASPX name of the control.
Instead, you need to use a modified version of the
controls ".UniqueID" property....

javaName = replace(txtName.UniqueID,":","_")
and use that name in your script.

Email if you need more.
-----Original Message-----
How do I retrieve a value from an ASP.NET Textbox in Java Script.

The following code returns Null, What am I doing wrong?

var AName = document.GetElementById("txtName.Value")

Changing "Value" to "Text" also returns Null, Also, if I remove "Value"
[object] is returned.

txtName is a ASPX textbox that the visitor places their name into.

Thanks
Chuck




.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top