473,386 Members | 1,621 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.

view state in previous page using cross page postback

Is there a way to retrieve values from the viewstate in the previouspage
using cross page postback?

Thanks!
Bill
Feb 16 '06 #1
6 5802
ASP.NET 2.0 resolves this by embedding a hidden input field name, __POSTBACK .
This field is embedded only when there is an IButtonControl on the page and
its PostBackUrl property is set to a non-null value.

The field contains the view state information of the poster page.

To access the view state of the poster page, you can use the new
PreviousPage property of the page:

Page poster = this.PreviousPage;

Then you can find any control from the previous page and read its state:

Label posterLabel = poster.findControl("myLabel");
string lbl = posterLabel.Text;

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"bill" wrote:
Is there a way to retrieve values from the viewstate in the previouspage
using cross page postback?

Thanks!
Bill

Feb 16 '06 #2
I think that what Bill wants is a way to access the viewstate on the
previous page so if you add any items to viewstate i.e
viewstate.add("whatever", "somedata") and then retrieving on the next
page the viewstate("whatever")...
Is that right Bill?

Feb 16 '06 #3
Yes, that is correct - sorry for not expressing it clearly.
"Giorgio" <ge*************@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I think that what Bill wants is a way to access the viewstate on the
previous page so if you add any items to viewstate i.e
viewstate.add("whatever", "somedata") and then retrieving on the next
page the viewstate("whatever")...
Is that right Bill?

Feb 16 '06 #4
Ah. Haven't found a way to do that.

Controls and their state, yes. The actual ViewState collection, no.

Of course, remember that ViewState is not designed for cross-page
operations. You can use Session, Cache, Application, or the HttpContext Items
collection for things like that, depending on which is appropriate.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"bill" wrote:
Yes, that is correct - sorry for not expressing it clearly.
"Giorgio" <ge*************@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I think that what Bill wants is a way to access the viewstate on the
previous page so if you add any items to viewstate i.e
viewstate.add("whatever", "somedata") and then retrieving on the next
page the viewstate("whatever")...
Is that right Bill?


Feb 16 '06 #5
Ok Bill, i found it for you! You cannot do that. Here is the Microsoft
note about what you want

"If the source and target page are in different applications, you
cannot directly get the values of controls on the page, but you can
read the posted data from the Form dictionary. You cannot read view
state from the source page, because it is hashed. If you want to store
values in the source page and make them available in a target page in
another application, you can store the values as strings inside hidden
fields on the source page and access them through Request.Form on the
target page."

http://msdn2.microsoft.com/en-us/lib...39(vs.80).aspx

Feb 17 '06 #6

I think I remember reading that, but thinking that they were still referring
to the source and target page being in different applications. I thought
that because the following sentence also refers to "another application".
Wishful thinking! I would like to use the viewstate because I have to store
a username/password and grab it in the target page, and I don't want to use
hidden fields since view source will reveal the password. I guess I'll try
using properties.

Thanks for your help!
Bill
"Giorgio" <ge*************@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Ok Bill, i found it for you! You cannot do that. Here is the Microsoft
note about what you want

"If the source and target page are in different applications, you
cannot directly get the values of controls on the page, but you can
read the posted data from the Form dictionary. You cannot read view
state from the source page, because it is hashed. If you want to store
values in the source page and make them available in a target page in
another application, you can store the values as strings inside hidden
fields on the source page and access them through Request.Form on the
target page."

http://msdn2.microsoft.com/en-us/lib...39(vs.80).aspx

Feb 17 '06 #7

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

Similar topics

2
by: Vinod I | last post by:
Hi Team, When I tryed following code, I am getting the Runtime Error as "The View State is invalid for this page and might be corrupted." Exception Details: System.Web.HttpException: The View...
3
by: Philip Tripp | last post by:
I've read numerous sources stating that view state can be disabled per control, and per page, but can't seem to keep web form controls from remembering their state on a postback. I'm using VS.Net...
7
by: Tom wilson | last post by:
I have created a very simple example that doesn't work. Form1 contains a textbox and a button: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
6
by: Bala | last post by:
Hi all, In my page load i am loading nearly 5 diffferent arrays. each array having nearly 1000 items. after that i am doing some calculation add some list into datagrid using that array values....
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
3
by: Neven Klofutar | last post by:
Hi, I recently read an article on MSDN about viewstate and postback. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/viewstate.asp The author states the following:...
1
by: John | last post by:
I am using the ItemDataBound event on the datagrid to place relevant images in the grid. However, when I press any button on the form which fires a postback the state of the grid is kept but the...
1
by: Jeff | last post by:
I need to place a "Previous Page" link on every page within my site and a simple javascript:history.back() will not work because I need it to capture the state of the page when I left it. For...
0
JimWu
by: JimWu | last post by:
I have some problems in my code. The stutiation illustrate as the followsing statement. I use two pages, one, named "upload.aspx", is including several general html input tag, whose type are...
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...
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
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
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.