473,327 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

still not working

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


Nov 17 '05 #1
3 2687
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
==============================
"Charles A. Lackman" <Ch*****@cet.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

Nov 17 '05 #2
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


.

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

Karl

"David Waz..." <dl*@pickpro.com> wrote in message
news:46****************************@phx.gbl...
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


.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: NeverLift | last post by:
I've searched around and don't find the following incident discussed specifically. First, a comment from an experience programmer new to JavaScript: While I am new to javascript, I've...
28
by: Andreas Prilop | last post by:
Jukka reports on http://www.cs.tut.fi/~jkorpela/chars/spaces.html that Internet Explorer 6 fails on the "zero width space" U+200B ​ Is this observation still valid? For which versions of MS...
13
by: Deano | last post by:
Hi, I generate a report using two dates (From and To). I notice if I enter 01/10/2003 that it is interpreted by Access as 10/01/2003 i.e 10th January rather than 1st October as I intended. ...
5
by: Bill Stock | last post by:
I'm inherited a database that has a few issues. One of the less severe issues, but the one the users bitch about is the speed across the LAN. So I thought that I could unbind the NUMEROUS subforms...
687
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
8
by: Brad Simon | last post by:
I have written a shopping cart using ASP .NET (VB). It has been running quite successfully on a site for about a year or so. I use the SessionID as the key to hold information on the shopping...
4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
6
by: vinnie | last post by:
hi guys, i'm just at the beginning. I apologize. the file still gives me back an error: <<Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'...
0
by: George2 | last post by:
Hello everyone, Sorry that this question is related to another question I posted some time before because I have some new findings and self-analysis. My question is why sometimes from perfmon...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.