473,320 Members | 1,876 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,320 software developers and data experts.

How do I access the DOM objects using javascript.

I have a problem in that I need to access the value (text) in an
asp:textbox using javascript. Is there any way to do this or am I all
wet? Do I have to use VBScript to access asp: objects?

Thanks in advance for your help!

Steve

Apr 27 '06 #1
5 1401
It's standard HTML by the time the browser gets it, so you can use standard
JavaScript (Or VBScript in IE) to access the DOM just as you would for any
web page.

Here's more info:
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Steve Kershaw" <st***********@yahoo.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
I have a problem in that I need to access the value (text) in an
asp:textbox using javascript. Is there any way to do this or am I all
wet? Do I have to use VBScript to access asp: objects?

Thanks in advance for your help!

Steve

Apr 27 '06 #2
I checked out the code you referenced and it all looks like server side
code to me. None of it is javascript. I need to run a javascript
"function" that collects the .text from the asp: textbox. But the
javascript dosen't recognize the asp:textbox as an HTML object.

Hmm....
Thanks

Steve

Apr 27 '06 #3
In experimenting around I find that:

<input type="text" name="mytext" > will work if I use javascript
document.aspnetForm.mytext.value = "Hi there";

However when the textbox is an asp: like:

<asp:TextBox ID="TextBox1" runat="server">My text 2</asp:TextBox> will
NOT WORK
with javascript: window.document.aspnetForm.TextBox1.Text = "Hi
again!";

It gives me an error message that states:
"window.document.aspnetForm.TextBox1 is null or not an object"

Steve Kershaw wrote:
I checked out the code you referenced and it all looks like server side
code to me. None of it is javascript. I need to run a javascript
"function" that collects the .text from the asp: textbox. But the
javascript dosen't recognize the asp:textbox as an HTML object.

Hmm....
Thanks

Steve


Apr 27 '06 #4
You should view the source in IE and see what id is assigned to that
textbox. Each control is given a client-side unique id, based on its
server-side id and the ids of its container controls.

For example a server-side textbox with the id of DataSetNameTextBox is
outputted as
<input
name="ctl00$ContentPlaceHolder1$fvwNormsDataSet$Da taSetNameTextBox"
type="text" value=":P" maxlength="50"
id="ctl00_ContentPlaceHolder1_fvwNormsDataSet_Data SetNameTextBox" />
, as it is contained by a formview, which is contained by a master page
placeholder, and so on.

As you can see, the textbox is outputted as an input, so trying to
access the Text property will result in a javascript error.

Apr 27 '06 #5
Look closer. The server side code is generating the client side code.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Steve Kershaw" <st***********@yahoo.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
I checked out the code you referenced and it all looks like server side
code to me. None of it is javascript. I need to run a javascript
"function" that collects the .text from the asp: textbox. But the
javascript dosen't recognize the asp:textbox as an HTML object.

Hmm....
Thanks

Steve

Apr 27 '06 #6

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

Similar topics

11
by: George Hester | last post by:
I have a css file this is a portion of it: /* trackaccept.css */ div.track { width:400px; height: 100px; } I have this in my ASP page:
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
2
by: stephane | last post by:
Hi all, What I am trying to achieve is an 'inherits' method similar to Douglas Crockford's (http://www.crockford.com/javascript/inheritance.html) but that can enable access to the superclass'...
9
by: Tony Lee | last post by:
Some time a ago, on this newsgroup the following comments were made in recommending good references for Access (2003) >I used to recommend Dr. Rick Dobson's, "Programming Access <version>" for...
13
by: Andy Baxter | last post by:
Can anyone recommend a good online guide to using objects in javascript? The book I bought (DHTML Utopia) suggests using objects to keep the code clean and stop namespace clashes between different...
2
by: TheDrizzle | last post by:
Hey All, I am using ADF UIX, which is a Oracle Framework to develop a web application. It is based off XML and translates the XML to HTML upon execution. The problem I'm having is it is creating...
7
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I access a property of an object using a string?...
3
pbmods
by: pbmods | last post by:
AN INTRODUCTION TO FUNCTION OBJECTS LEVEL: INTERMEDIATE PREREQS: OBJECTS You've seen it before. You're setting up an XMLHttpRequest call, and you need to execute a function when it returns, so...
7
by: tshad | last post by:
How do you hide an asp.net object and still be able to access it? I had my email in a session variable, but you can't access the session variable from Javascript (I don't think - since Javascript...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: 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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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

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.