473,407 Members | 2,314 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,407 software developers and data experts.

Read Page Control Values from Javascript User Control

Roy
How do I read the value of an html input control from inside a javascript
user control?

An aspx page contains a user control that attempts to read a value from an
html input control in the aspx page.

For example:

In the aspx page, the control is defined as:
<input id="txtTMOStart" runat="server" name="txtTMOStart" type="TEXT"
size="30" value="test" enableviewstate="true" />

The Javascript user control attempts to read the value from the control:
var controlValue = document.aspnetForm.txtTMOStart.value;

However, controlValue is always null even thought the control is initialized
with a value.

Note:
If the runat="server" attribute is removed from the html control, the value
returned is not null, however, I can't read the control’s value from the code
behind file!

Any ideas?

Thanks.
Oct 30 '06 #1
10 1967
Did you try document.getElementById("txtTMOStart" )?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Roy" <Ro*@discussions.microsoft.comwrote in message
news:73**********************************@microsof t.com...
How do I read the value of an html input control from inside a javascript
user control?

An aspx page contains a user control that attempts to read a value from an
html input control in the aspx page.

For example:

In the aspx page, the control is defined as:
<input id="txtTMOStart" runat="server" name="txtTMOStart" type="TEXT"
size="30" value="test" enableviewstate="true" />

The Javascript user control attempts to read the value from the control:
var controlValue = document.aspnetForm.txtTMOStart.value;

However, controlValue is always null even thought the control is
initialized
with a value.

Note:
If the runat="server" attribute is removed from the html control, the
value
returned is not null, however, I can't read the control's value from the
code
behind file!

Any ideas?

Thanks.

Oct 30 '06 #2
Roy
Yes...same result. Thanks for your response.

"Eliyahu Goldin" wrote:
Did you try document.getElementById("txtTMOStart" )?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Roy" <Ro*@discussions.microsoft.comwrote in message
news:73**********************************@microsof t.com...
How do I read the value of an html input control from inside a javascript
user control?

An aspx page contains a user control that attempts to read a value from an
html input control in the aspx page.

For example:

In the aspx page, the control is defined as:
<input id="txtTMOStart" runat="server" name="txtTMOStart" type="TEXT"
size="30" value="test" enableviewstate="true" />

The Javascript user control attempts to read the value from the control:
var controlValue = document.aspnetForm.txtTMOStart.value;

However, controlValue is always null even thought the control is
initialized
with a value.

Note:
If the runat="server" attribute is removed from the html control, the
value
returned is not null, however, I can't read the control's value from the
code
behind file!

Any ideas?

Thanks.


Oct 31 '06 #3
Is the input control inside the user control?
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Roy" <Ro*@discussions.microsoft.comwrote in message
news:4B**********************************@microsof t.com...
Yes...same result. Thanks for your response.

"Eliyahu Goldin" wrote:
>Did you try document.getElementById("txtTMOStart" )?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Roy" <Ro*@discussions.microsoft.comwrote in message
news:73**********************************@microso ft.com...
How do I read the value of an html input control from inside a
javascript
user control?

An aspx page contains a user control that attempts to read a value from
an
html input control in the aspx page.

For example:

In the aspx page, the control is defined as:
<input id="txtTMOStart" runat="server" name="txtTMOStart" type="TEXT"
size="30" value="test" enableviewstate="true" />

The Javascript user control attempts to read the value from the
control:
var controlValue = document.aspnetForm.txtTMOStart.value;

However, controlValue is always null even thought the control is
initialized
with a value.

Note:
If the runat="server" attribute is removed from the html control, the
value
returned is not null, however, I can't read the control's value from
the
code
behind file!

Any ideas?

Thanks.



Oct 31 '06 #4
Roy
No, the input control is in the aspx page.

Oct 31 '06 #5
Check the html source of the page when is it rendered in your browser. You
should be able to see the real id of the control.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Roy" <Ro*@discussions.microsoft.comwrote in message
news:26**********************************@microsof t.com...
No, the input control is in the aspx page.

Nov 1 '06 #6
Roy
I have no problem reading the id of the control. The problem I’m having is
retrieving the *value* the control contains. Yet, if I remove the attribute
“runat=’server’” from the declaration of the control, the value is not null
and I can retrieve it.
Nov 1 '06 #7
Can you check how does the html for the input control look like when you
have runat=server?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Roy" <Ro*@discussions.microsoft.comwrote in message
news:03**********************************@microsof t.com...
>I have no problem reading the id of the control. The problem I'm having is
retrieving the *value* the control contains. Yet, if I remove the
attribute
"runat='server'" from the declaration of the control, the value is not
null
and I can retrieve it.

Nov 1 '06 #8
Roy
As I wrote in the my initial post and if I understand your statement, the
html for the html input control looks like:

<input id="txtTMOStart" runat="server" name="txtTMOStart" type="TEXT"
size="30" value="test" enableviewstate="true" />

Nov 1 '06 #9
No, I mean the real html that is produced by asp.net and arrives to your
browser. It doesn't have neither runat nor enableviewstate attributes since
those are server ones. Your javascript is dealing with this real html and I
suspect the html for the control in topic may look differently from what you
think.

To see the real html, get the page on your browser screen, right-click the
mouse and select "View Source" option. This is how it's called in IE, other
browsers may have different names for the same thing. The html for the page
will open in an editor window. Search for "txtTMOStart" and see what element
is that.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Roy" <Ro*@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
As I wrote in the my initial post and if I understand your statement, the
html for the html input control looks like:

<input id="txtTMOStart" runat="server" name="txtTMOStart" type="TEXT"
size="30" value="test" enableviewstate="true" />

Nov 1 '06 #10
Roy
Right...that's one of the first things I did.
Nov 1 '06 #11

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

Similar topics

0
by: Earl Teigrob | last post by:
I have a page that reads values from an XML file to display to the user. The page also has a control panel that allows administrators to update the XML file with new values. When an administrator...
9
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
10
by: Andrew | last post by:
Hi ALL, I have a javascript code which i register using page.RegisterClientScriptBlock() in my btnFinish() button_click event. I noticed that the debugger will run thru the whole event for my...
14
by: MLH | last post by:
I use A97. I've gotten used to reading values from textbox controls on forms, I've come to rely on it pretty heavily. My habit spills over into reports. I'm uncertain whether I can reliably read...
0
by: skberen | last post by:
Issue: We have a web user control on a web page (aspx) that uses the new ASP.Net 2 feature Client Callback. The web user control is using a CheckBoxList control and button control to allow the...
4
by: Raj | last post by:
Hi, I am struggling with this for quite some time and thought will seek your help on it. What I am doing is, I have Page1.aspx where user inputs text into text boxes and also has a link to...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.