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

shouldn't viewstate work for this?

Hi I am setting a boolean value to true on a page and writing the results to viewstate
Just above the web form designer generated code I have
Dim bps_found As Boolean 'visible to this module

in a button click event I have
bps_found=true
ViewState("ps_found") = bps_found 'save value in viewstate
then a redirect to another page, passing string information.
in the page load I have
bps_found = ViewState("ps_found") 'get value from viewstate

I put a break point in the page load and noticed after the click event when
renavigating to the page the value always stays false, when it should be true.
Thanks
--
Paul G
Software engineer.
Nov 18 '05 #1
3 1291
"=?Utf-8?B?UGF1bA==?=" <Pa**@discussions.microsoft.com> wrote in
news:F9**********************************@microsof t.com:
ViewState("ps_found") = bps_found 'save value in viewstate
then a redirect to another page, passing string information.
in the page load I have
bps_found = ViewState("ps_found") 'get value from viewstate


Viewstate is only valid for a single page - the value does not get
propogated to a second page.

Use a session variable instead.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2
ViewState is only used on a single page that handles postbacks. Once you
redirect to the new page, the ViewState is lost. The reason for this is that
ViewState is actually stored in a hidden input field on the HTML form. Thus,
every time the page is posted back, ASP.Net reconstructs the ViewState
object from the hidden input field. However, the new page that you redirect
to does not have this context.

If you need to get the value to the next page, you should either use a
cookie, or the session object.

Ben Lucas
Lead Developer
Solien Technology, Inc.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:F9**********************************@microsof t.com...
Hi I am setting a boolean value to true on a page and writing the results to viewstate Just above the web form designer generated code I have
Dim bps_found As Boolean 'visible to this module

in a button click event I have
bps_found=true
ViewState("ps_found") = bps_found 'save value in viewstate
then a redirect to another page, passing string information.
in the page load I have
bps_found = ViewState("ps_found") 'get value from viewstate

I put a break point in the page load and noticed after the click event when renavigating to the page the value always stays false, when it should be true. Thanks
--
Paul G
Software engineer.

Nov 18 '05 #3
If you want to persist this over sessions, you could look at IsolatedStorage
classes in the IO.ISOLATEDSTORAGE namespace.

HTH

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
ok thanks for the information. The page gets closed and reloaded several times with a typical user so sounds the viewstate information would
be lost and the session variable/object should work.
--
Paul G
Software engineer.
"Ben Lucas" wrote:
ViewState is only used on a single page that handles postbacks. Once you
redirect to the new page, the ViewState is lost. The reason for this is that ViewState is actually stored in a hidden input field on the HTML form. Thus, every time the page is posted back, ASP.Net reconstructs the ViewState
object from the hidden input field. However, the new page that you redirect to does not have this context.

If you need to get the value to the next page, you should either use a
cookie, or the session object.

Ben Lucas
Lead Developer
Solien Technology, Inc.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:F9**********************************@microsof t.com...
Hi I am setting a boolean value to true on a page and writing the
results to viewstate
Just above the web form designer generated code I have
Dim bps_found As Boolean 'visible to this module

in a button click event I have
bps_found=true
ViewState("ps_found") = bps_found 'save value in viewstate
then a redirect to another page, passing string information.
in the page load I have
bps_found = ViewState("ps_found") 'get value from viewstate

I put a break point in the page load and noticed after the click event

when
renavigating to the page the value always stays false, when it should
be true.
Thanks
--
Paul G
Software engineer.


Nov 18 '05 #4

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

Similar topics

5
by: Christian | last post by:
Hi, Viewstate of WebUserControl does NOT work although the 'EnableViewstate'-property of the usercontrol is set to true Description : Using ASP.Net : I have a created a WebPage with 2...
2
by: Christian | last post by:
Hi, Viewstate of WebUserControl does NOT work although the 'EnableViewstate'-property of the usercontrol is set to true Description : Using ASP.Net : I have a created a WebPage with 2...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
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...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
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);...
1
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled...
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...
2
by: dotComPaJi | last post by:
Hello There, I have a simple question. In one of my program if I use ViewState then program does not work as expected(nothing is displayed in GridView but If I use Session State then it works...
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: 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...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.