473,382 Members | 1,615 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,382 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 2307
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.