473,385 Members | 1,856 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,385 software developers and data experts.

viewstate question

I'm using a viewstate key/value to store a serialized instance of a class.
If I redirect to another aspx page, the viewstate is lost. Is this the
intended behavior of the viewstate? Is there a work around? Cookies, I
suppose.

Thanks,

Craig Buchanan
Nov 18 '05 #1
5 1619
Hi,

by default ViewState is page-specific. And yes, it is designed to be so.
Workaround can be basically anything where you can serialize your class
instance like cookie (means just serilalization to string in that case).
Easiest way to get over it would be using Session as in InProc mode it can
hold any class instance without serializing.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:eV*************@TK2MSFTNGP11.phx.gbl...
I'm using a viewstate key/value to store a serialized instance of a class.
If I redirect to another aspx page, the viewstate is lost. Is this the
intended behavior of the viewstate? Is there a work around? Cookies, I
suppose.

Thanks,

Craig Buchanan

Nov 18 '05 #2
hi,
ViewSate works on "hidden" textboxes placed on a particular page
i.e pageSpecific
if u want to maintain state over pages. then there
are:
Session and
Cookies to rely on ..
there is also the Cache class to work witth
which can persist over pages.

bye

amit
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:eV*************@TK2MSFTNGP11.phx.gbl...
I'm using a viewstate key/value to store a serialized instance of a class.
If I redirect to another aspx page, the viewstate is lost. Is this the
intended behavior of the viewstate? Is there a work around? Cookies, I
suppose.

Thanks,

Craig Buchanan

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 1/27/2004
Nov 18 '05 #3
Amit-

Thanks for the response. Two questions:

1) are .Net session objects scalable?
2) what are the pros/cons for a cache class?

Thanks,

Craig

"Amit Agarwal" <ammnbgd@rediffcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
hi,
ViewSate works on "hidden" textboxes placed on a particular page
i.e pageSpecific
if u want to maintain state over pages. then there
are:
Session and
Cookies to rely on ..
there is also the Cache class to work witth
which can persist over pages.

bye

amit
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:eV*************@TK2MSFTNGP11.phx.gbl...
I'm using a viewstate key/value to store a serialized instance of a class. If I redirect to another aspx page, the viewstate is lost. Is this the
intended behavior of the viewstate? Is there a work around? Cookies, I
suppose.

Thanks,

Craig Buchanan

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 1/27/2004

Nov 18 '05 #4
Persisting data is a real problem in ASP.Net due to the stateless nature of
HTTP. When talking about persisting a value, you need to think about scope.
How long do you want the variable to exist? What should it be exposed to?
For example, should it have Application Scope, so that any page being viewed
by any user can access it? Should it be in Session State, so that each user
has their own separate variable that remains for the lifetime of the User
Session? Should it have Page scope, such as ViewState, so that it is
persisted only for the duration of the current Page and PostBacks of that
Page? Should it be stored in a database, where it will persist permanently,
and is still avialable to any Page that needs it for any user? The more
carefully you consider this question, the less you'll have to change later.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:eV*************@TK2MSFTNGP11.phx.gbl...
I'm using a viewstate key/value to store a serialized instance of a class.
If I redirect to another aspx page, the viewstate is lost. Is this the
intended behavior of the viewstate? Is there a work around? Cookies, I
suppose.

Thanks,

Craig Buchanan

Nov 18 '05 #5
no,
in a web app there are hundreds of users hitting a site..
so ifu put everything in session say ten variables in session
so for 100 users i will multiply
and so that much load on the server.
so one shud uses session sparingly

for imp tasks only like
username.

where r u from ..

amit agarwal
india

"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
Amit-

Thanks for the response. Two questions:

1) are .Net session objects scalable?
2) what are the pros/cons for a cache class?

Thanks,

Craig

"Amit Agarwal" <ammnbgd@rediffcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
hi,
ViewSate works on "hidden" textboxes placed on a particular page
i.e pageSpecific
if u want to maintain state over pages. then there
are:
Session and
Cookies to rely on ..
there is also the Cache class to work witth
which can persist over pages.

bye

amit
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:eV*************@TK2MSFTNGP11.phx.gbl...
I'm using a viewstate key/value to store a serialized instance of a class. If I redirect to another aspx page, the viewstate is lost. Is this the intended behavior of the viewstate? Is there a work around? Cookies, I suppose.

Thanks,

Craig Buchanan

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 1/27/2004


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.573 / Virus Database: 363 - Release Date: 1/28/2004
Nov 18 '05 #6

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...
3
by: Kevin Gorski | last post by:
This question has been asked before, but there have been no definitive answers that I was able to find. Can the viewstate hidden input field be moved to a less prominent page location? On an...
1
by: Simon | last post by:
Hi everyone, I have a quick question that I hope someone can help me with: I've made a user control that contains a text box and some validation functionality. This control has a few extra...
7
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
6
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a...
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...
1
by: Mark Olbert | last post by:
I have a "master" composite control which, in turn, holds an instance of a "detail" composite control (the "master" control will ultimately contain multiple instances of the "detail" control, but...
3
by: Justin | last post by:
I have aspx pages with 10 checkboxlist controls. total individual checkbox (the sum of individual checbox in those 10 checkboxlists) on the page is about 1710. You can imagine how large the...
9
by: =?Utf-8?B?TUNN?= | last post by:
I'm sure the answer to my question varies depending on the situation, but I am looking for a general "best practice". If I have an asp.net application and I load certain data from a database,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.