471,339 Members | 1,193 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,339 software developers and data experts.

Using ViewState to pass variables

Hi,
would like to know whether I can use ViewState to pass variables from one
web page to another. I've been trying do this but all I managed to do is to
pass the variable to the target page but am unable to extract the variable
out to print on the page. The source of the target page reflects a ViewState
value being passed. My code is as below:
(On 1st page)
ViewState("name") = Name
Response.Redirect("targetpage.aspx")

(On targetpage.aspx)
Name: <% Response.Write(CStr(ViewState("name")))%>

(Source of targetpage.aspx)
<form name="_ct10" method="post" action="targetpage.aspx" id="_ct10">
<input type="hidden" name="__VIEWSTATE" value="some gibberish string" />

Anything wrong with my code or do I need to import additional namespace?

Rgds,
blurz
Jul 21 '05 #1
2 2167
Blurz,

Between pages, in a normal way, No.

Use a session.item (any other method is mostly a lot of work or/and not real
reliable)

I hope this helps,

Cor
Jul 21 '05 #2
Hi ,

As far as I could read on the ViewState is use to store in a hidded field on
a page.
In addition to that it is limited to item that can be serialized.
Asp.net handle ViewState content in hash data in order to avoid kind of
ackibg from server side.

If you want to keep track of variable during the life time of your
application its better and recomanded to use Application or Session object

Hope it helps
regards
serge

"Cor Ligthert" wrote:
Blurz,

Between pages, in a normal way, No.

Use a session.item (any other method is mostly a lot of work or/and not real
reliable)

I hope this helps,

Cor

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by neo | last post: by
reply views Thread by bill | last post: by
6 posts views Thread by Max | last post: by
9 posts views Thread by Mark Broadbent | last post: by
6 posts views Thread by Gauthier Segay | last post: by
6 posts views Thread by Patrick.O.Ige | last post: by
2 posts views Thread by blurz | last post: by
reply views Thread by rosydwin | last post: by

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.