By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 927 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

Changing hidden values

P: n/a
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated before the page is changed?

I want to say that because the values are changed but the page is never reloaded after the change, that these changes do not take effect before the server.transfer. Please let me know if I am correct here. I think I am finally getting the hang of asp.net.

Thanks,

Jeremy Ames
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
A good way to find out is by turning on debugger and inspect values.

Charlie
"Jeremy Ames" <yo******@here.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
I have a form that contains two hidden values, among other controls. I was
wondering, if I change these values in server script and immediately do a
server.transfer, do these values get updated before the page is changed?

I want to say that because the values are changed but the page is never
reloaded after the change, that these changes do not take effect before the
server.transfer. Please let me know if I am correct here. I think I am
finally getting the hang of asp.net.

Thanks,

Jeremy Ames
Nov 18 '05 #2

P: n/a
When you do a Server.Transfer, the called page has access to the Querystring
and Forms collections of the original server post. The transfering page is
unloaded, so all data there will be gone. The called page is a new instance
of the new page, so you are starting a fresh Page instance.

Jeffrey Palermo
"Jeremy Ames" <yo******@here.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
I have a form that contains two hidden values, among other controls. I was
wondering, if I change these values in server script and immediately do a
server.transfer, do these values get updated before the page is changed?

I want to say that because the values are changed but the page is never
reloaded after the change, that these changes do not take effect before the
server.transfer. Please let me know if I am correct here. I think I am
finally getting the hang of asp.net.

Thanks,

Jeremy Ames
Nov 18 '05 #3

P: n/a
Hi Jeremy,

It will help if you don't think of your executable code as "script" but
objects instead. ASP.Net has 2 components in every Page: The server-side
objects, and the client-side HTML. Neither of these necessarily has much to
do with the other. It's more useful to think of them sending messages to
each other. That is, the server-side objects which generate the client-side
HTML "send messages" by changing the HTML in the page. The client-side HTML
"sends messages" by posting back to the server. Stick with me, and shortly
you'll understand why I'm putting it this way.

You say that you have "a form that contains two hidden values." However,
that form has 2 components to it: The server-side objects, and the
client-side HTML. The server-side objects can certainly create hidden form
fields in the client-side HTML. However, these client-side form fields are
not necessarily connected in any way with a server-side objects. After all,
HTML is just text. You could create a client-side hidden form field by
simply writing the appropriate HTML into your Response. If that is indeed
what you did, how will the server-side objects have any notion that you
changed their values? There are no corresponding objects on the server to
which they are wired.

When you do a Server.Transfer, you are performing a purely server-side
operation. No Response is sent to the browser, and the HTML that resided in
the browser is history. You are simply transferring the HttpContext from one
Handler (Page object) to another. Only objects in memory will be
transferred. In order to transfer some client-side form value to the new
Handler, you have to either use server-side objects (such as
HtmlInputHidden) or place the values from the Request.Form Collection that
are not linked to any server-side objects INTO a server-side object, such as
a Public field or Property of the Page object. Or, you could just put the
values directly into the HttpContext. Any in-memory server-side object that
is accessible from the HttpContext after the transfer will be fine.

I hope the long explanation will help you to further get the hang of
ASP.Net. :)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Jeremy Ames" <yo******@here.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
I have a form that contains two hidden values, among other controls. I was
wondering, if I change these values in server script and immediately do a
server.transfer, do these values get updated before the page is changed?

I want to say that because the values are changed but the page is never
reloaded after the change, that these changes do not take effect before the
server.transfer. Please let me know if I am correct here. I think I am
finally getting the hang of asp.net.

Thanks,

Jeremy Ames
Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.