473,411 Members | 2,019 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,411 software developers and data experts.

I'm confused (Viewstate and Context)

Hi,

I'm trying to pass information between pages. I'm trying to avoid using
QueryString and Session variables. I saw somewhere that I could use
contxt.Items.Add (combined with Server.Transfer) to store my
information and send it to another page. Some of my pages, either go to
other pages, or postback depending on the situation. When I began to
get confused was when I saw that I needed to store my variables on the
viewstate if I wanted to postback. So any answers to the next questions
could really help me understand all of this.

1. Isn't the context stored on the viewstate?
2. If that's the case, what would be the use of using the context
object if I'm going to end up storing everything on the viewstate to
get the info on postback, and also wouldn't I be duplicating my
viewstate when I and I reset my context variables, to do
Server.Transfer, because my viewstate already has that info.
3. What would be the best way to pass information, I'm only trying to
persist three variables, nothing more than that.

I know I must probably misunderstood the context object or the
viewstate. I really need somebody to get me out of my confusion.

Thanks

Nov 19 '05 #1
1 1424
"Hugo Flores" <hu*********@ge.com> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
1. Isn't the context stored on the viewstate?
No, context items are sent as part of the server.transfer. After the
server.transfer, context items are disposed.
2. If that's the case, what would be the use of using the context
object if I'm going to end up storing everything on the viewstate to
get the info on postback, and also wouldn't I be duplicating my
viewstate when I and I reset my context variables, to do
Server.Transfer, because my viewstate already has that info.
You can't send viewstate between pages.
3. What would be the best way to pass information, I'm only trying to
persist three variables, nothing more than that.


Page A, use httpcontext to send the variables to Page B. In Page B, save
the variables to a viewstate variable which can be used during a
postback.

Or, use a session variable.

Or use a querystring.

There's nothing wrong with using a querystring - if you're querying
against public data (i.e. non secured data).
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
hi to all does any body know or receive this message before and how i can repare this: The viewstate is invalid for this page and might be corrupted. thank's Mike
10
by: Lloyd Dupont | last post by:
When you define UserControl in source code the sample I see are often like that: ============ public string Text { get { String s = (String)ViewState; return ((s == null) ? String.Empty : s);...
7
by: GS | last post by:
Hello, I'm receiving The state information is invalid for this page and might be corrupted error message when running code below. This happens on second post back. Why is it happening? My...
4
by: John | last post by:
Hi, I derived a class from the Hashtable class, with ISerializable implemented and the tag added. Everything works fine with one exception. I store the hashtable in ViewState, but on a...
6
by: mosscliffe | last post by:
I am testing for how/when a page is posted back and I decided to use a ViewState variable in PageLoad to set up a counter, but it appears, the ViewState is cleared on each PageLoad. So then I used...
1
by: Dhruba Bandopadhyay | last post by:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm....
0
by: tynorton | last post by:
Hey, I've been working on this issue for a while now, with no leads or success. The scenario is a homemade modal dialog using UpdatePanels. There a couple ImageButtons inside of usercontrols...
5
by: John Kotuby | last post by:
Hi all, After more than a year programming with ASP.NET 2.0 and VB I am still finding it difficult to leave some habits from classic ASP behind. this is particularly true with cross-page posting....
3
by: sck10 | last post by:
Hello, I have a web project (VS 2008 c#). I have a page that opens, but when I try to call an assembly (managed c++) on a submit event, I get the following error on the web server, but not on...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.