still not working

  • Thread starter Thread starter Charles A. Lackman
  • Start date 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
 
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
==============================
 
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.
 
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




.
 
Back
Top