473,289 Members | 1,875 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,289 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 5796
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.