Re: Client side changes not reflected in page
- From: Milosz Skalecki [MCAD] <mily242@xxxxxxxxxxxxxxxxx>
- Date: Thu, 1 Feb 2007 08:49:01 -0800
Hi Patrick,
I see the problem is that you don't quite understand how it works. Every
time you request a page from the browser, asp.net generates a HTML document
that is sent back and parsed by the browser. In addition to that browser
builds DOM objects based on parsed document so you could interact with
document on the client side via JavaScript / VBScript. That’s the bit you
seem to understand. Now (simplifying), if you want to send page back to the
server, only small part of the information is passed in POST request - a
special form is built to store values for <input> controls only (textbox,
radio button, button, select, etc.), so if you added or changed any property
via JavaScript (apart from input.value) it won’t be reflected in the form. In
other words, browser does not send changed HTML document back as you may
think, it sends input information only. Asp.net engine parses this
information and updates compiled page that’s literally a wrapper around the
HTTP request (community guys - please forgive me for simplifying, Op seems to
lack this knowledge). If you want to know the value of the client side
variable / property use hidden input to store it – it’ll be then available on
the server side, or use AJAX asynchronous calls (more advanced).
Hope everything is clear now
Regards
Milosz
--
Milosz
"patrickdrd" wrote:
I've had the exact problem both in ASP.NET 1.1 and now I'm facing it in 2.0.
as well!
Well, the case is this
(I'll mention the 1.1 case, which is easier to tell):
on a user input form (data entry - update a customer, let's say),
the user types the new data and presses the update button to commit the
changes,
however, javascript is called before the postback in order to validate the
input values,
if something goes wrong prompts the user to correct,
and, when everything is ok, posts the page to the server.
If I change a single value on a single field with javascript on this example
and then post back the page to the server, that change can't be seen by the
server,
while user values and changes of the fields can!
Why? How is that?
"Mark Rae" wrote:
"patrickdrd" <patrickdrd@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FF279E8C-84A8-489A-9B46-6C8265493AF8@xxxxxxxxxxxxxxxx
Patrick,
Well, ok, forget about the page's source,
my mistake mentioning this,
It's a common misconception... :-)
my real problem is that the variable show its 'original' value when
submitted to the server and not the one that javascript changed to!
Why isn't that variable/field 'refreshed'?
Do I need to do something (like a 'refresh')?
This, however, is a different issue...
Client-side data changes, whether caused by user typing or JavaScript,
should certainly survive a postback.
You'll need to post your code...
- Follow-Ups:
- Re: Client side changes not reflected in page
- From: Mark Rae
- Re: Client side changes not reflected in page
- References:
- Re: Client side changes not reflected in page
- From: bruce barker
- Re: Client side changes not reflected in page
- From: patrickdrd
- Re: Client side changes not reflected in page
- From: Mark Rae
- Re: Client side changes not reflected in page
- Prev by Date: Re: Creating Word Documents
- Next by Date: newbie: <div> trouble
- Previous by thread: Re: Client side changes not reflected in page
- Next by thread: Re: Client side changes not reflected in page
- Index(es):