Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a web control from within javascript...

Status
Not open for further replies.

Ime532

IS-IT--Management
Apr 1, 2004
89
US
I'm learning web development in .NET (coming from windows only programming in VB 6.0) and there appears to be a problem with the code in the book i'm using. The problem is, I've added a web control called txtName to the form and from within javascript, I reference it with this code:

alert(document.Form1.txtName.Value)

The problem is: 1. txtName doesn't show up as an object when I start typing this and 2. When the message box pops up when i view the project in the browser it simply says "undefined"

If I remove the web control and use an HTML control, it shows up under document.Form1.txtName2 (that's the name I used for it) but when I put alert(document.Form1.txtName2.InnerText) the prompt is blank.

What is missing here that is not letting the form be "aware" of this web control???? Thanks in advance. If you need the code I can post it but I'm guessing it's something simple.
 
FYI i AM able to reference txtName inside the .vb file and it correctly displays the value so for some unknown reason it can't display the value of this control in the HTML file.
 
Update, I got it to work if I use an HTML control, it no longer comes up blank.

I still can't get it to work if I use a webcontrol. What do I have to do to allow javascript to see the web control??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top