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

Client-Side Hidden Field Update Problem

In an aspx file I have declared a hidden field like this:
<input id="hTestVal" type=hidden value="-1" runat="server">

Defined in the code-behind like this:
protected System.Web.UI.HtmlControls.HtmlInputHidden hTestVal;

In client-side JavaScript I set the value like this:
document.all("hTestVal").Value = "yo";

The problem is that the value of the hidden field (hTestVal) does not get
updated (It is not updated on Postback, and when I view the source of the
rendered aspx page in IE6, the value is still "-1" even though the
client-side script has executed (to set the value to "yo").

I believe the value is in fact getting updated in the client, because the
following line, when executed immediately after setting the value to "yo"
produces the/that new value:
alert(document.all("hTestVal").Value);

FWIW, the hidden control is declared within a form, like this:
<form id="Form1" method="post" runat="server">

I'm confused because I have a virtually identical setup in other pages in my
site and those hidden fields and client-side value changes work just fine...
meaning that the value set in the client-side script shows up in the control
on the server during postback as expected.

What could be the deal? I need to receive the updated value (e.g., "yo") in
the server on postback.

Thanks
Nov 18 '05 #1
2 5107
input controls do not have a "Value" property, so your client code creates
one and sets the its value, the alert displays the value of this new
property. try updating the "value" property, which is what the control posts
back.

also you are using obsolete dom methods, which future ms browsers may not
support.

try:

document.getElementById("hTestVal").value = "yo";

which works with all w3c compliant browsers.

-- bruce (sqlwork.com)
"Guadala Harry" <GM**@NoSpam.com> wrote in message
news:eI*************@tk2msftngp13.phx.gbl...
In an aspx file I have declared a hidden field like this:
<input id="hTestVal" type=hidden value="-1" runat="server">

Defined in the code-behind like this:
protected System.Web.UI.HtmlControls.HtmlInputHidden hTestVal;

In client-side JavaScript I set the value like this:
document.all("hTestVal").Value = "yo";

The problem is that the value of the hidden field (hTestVal) does not get
updated (It is not updated on Postback, and when I view the source of the
rendered aspx page in IE6, the value is still "-1" even though the
client-side script has executed (to set the value to "yo").

I believe the value is in fact getting updated in the client, because the
following line, when executed immediately after setting the value to "yo"
produces the/that new value:
alert(document.all("hTestVal").Value);

FWIW, the hidden control is declared within a form, like this:
<form id="Form1" method="post" runat="server">

I'm confused because I have a virtually identical setup in other pages in my site and those hidden fields and client-side value changes work just fine... meaning that the value set in the client-side script shows up in the control on the server during postback as expected.

What could be the deal? I need to receive the updated value (e.g., "yo") in the server on postback.

Thanks

Nov 18 '05 #2
In continuing to research this, one difference between the pages that work
and the "problem page" (as described in the original post) is that the
"problem page" is rendered within a frame(set). Could this be relevant? NOTE
that all the code in question (client-side and code-behind) is all for the
same aspx page - and not between pages in the frameset. In other words, I'm
*not* trying to read the hidden field from another page's code-behind.

Still looking for a direction to go with this... Thanks!

"Guadala Harry" <GM**@NoSpam.com> wrote in message
news:eI*************@tk2msftngp13.phx.gbl...
In an aspx file I have declared a hidden field like this:
<input id="hTestVal" type=hidden value="-1" runat="server">

Defined in the code-behind like this:
protected System.Web.UI.HtmlControls.HtmlInputHidden hTestVal;

In client-side JavaScript I set the value like this:
document.all("hTestVal").Value = "yo";

The problem is that the value of the hidden field (hTestVal) does not get
updated (It is not updated on Postback, and when I view the source of the
rendered aspx page in IE6, the value is still "-1" even though the
client-side script has executed (to set the value to "yo").

I believe the value is in fact getting updated in the client, because the
following line, when executed immediately after setting the value to "yo"
produces the/that new value:
alert(document.all("hTestVal").Value);

FWIW, the hidden control is declared within a form, like this:
<form id="Form1" method="post" runat="server">

I'm confused because I have a virtually identical setup in other pages in my site and those hidden fields and client-side value changes work just fine... meaning that the value set in the client-side script shows up in the control on the server during postback as expected.

What could be the deal? I need to receive the updated value (e.g., "yo") in the server on postback.

Thanks

Nov 18 '05 #3

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

Similar topics

1
by: ian maclure | last post by:
I'm writing a client-server app. Client controls Server which in turn configures and controls a bunch of hardware. I want to be able to start the server from my client. Now in C/C++ one could...
2
by: Raquel | last post by:
How do I know whether the 'runtime client' and the 'application development client' are installed on my machine? When I issue the command "db2licm -l", it gives the following output: Product...
0
by: Tim Northrup | last post by:
Help! We have DB2 V7.2 (fixpak 12) installed on Windows2003 Server, and the latest V7.2 client installed on another system. The DB2CODEPAGE on all systems is set to 1208, and the database was...
2
by: Rhino | last post by:
I am trying to verify that I correctly understand something I saw in the DB2 Information Center. I am running DB2 Personal Edition V8.2.1 on Windows. I came across the following in the Info...
8
by: Ankit Aneja | last post by:
i am doing here some some socket-client work in C# windows service it is working fine for multiple clients now i want to limit these multiple clients to 25 for example i want that when service...
13
by: Sandeep Singh | last post by:
I am making socket client application in C# how can i get ip address of client who has connected to server
14
by: Ankit Aneja | last post by:
The code of classes given below is for server to which clients connect i want to get ip address of client which has connected pls help how can i get //listen class public class listen {
0
by: khu84 | last post by:
Here is client server very simple code, seems to work with telnet but with with web client code gives blank output. Following is the server code:- <?php function...
2
by: nsaffary | last post by:
hi I hava a client/server program that run correctly when i run it in one computer(local) but when I run client on a one computer and run server run on another, connection does not stablish.(I set...
4
MMcCarthy
by: MMcCarthy | last post by:
http://bytes.com/images/howtos/projectscope_blocks.jpgAs a freelance IT consultant for over 10 years, I’ve come to appreciate well defined project scopes. A project scope is a common understanding...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.