473,386 Members | 1,715 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,386 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 2310
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and...
0
by: bill | last post by:
I'm upgrading an existing IIS application to .NET webforms. I need to preserve the existing look/feel - a covnentional 3-pane frameset with a header, left-side treeview menu, and content frame on...
6
by: Max | last post by:
I need an vb.net class that is invoked from aspx page, that use the viewstate/session object. This class must be store the information into viewstate/session. Can you give me an example ? Thanks
9
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct...
6
by: Gauthier Segay | last post by:
Hello, I've problem on subsequent postbacks after a Server.Transfer was done. In our application framework we have a method that pass parameters (via HttpContext.Items) and navigate to another...
6
by: Patrick.O.Ige | last post by:
I'm constructing a link from a viewstate and passing it on to a querystring.. After clciking a checkboxlist i add the value to a viewstate and return it but on the same page i also have a...
15
by: Joe Fallon | last post by:
I would like to know how you can figure out how much memory a given instance of a class is using. For example, if I load a collection class with 10 items it might use 1KB, and if I load it with...
2
by: blurz | last post by:
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.