Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > view state in previous page using cross page postback

Reply
Thread Tools

view state in previous page using cross page postback

 
 
bill
Guest
Posts: n/a
 
      02-16-2006
Is there a way to retrieve values from the viewstate in the previouspage
using cross page postback?

Thanks!
Bill


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      02-16-2006
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
>
>
>

 
Reply With Quote
 
 
 
 
Giorgio
Guest
Posts: n/a
 
      02-16-2006
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?

 
Reply With Quote
 
bill
Guest
Posts: n/a
 
      02-16-2006
Yes, that is correct - sorry for not expressing it clearly.
"Giorgio" <> wrote in message
news: 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?
>



 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      02-16-2006
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" <> wrote in message
> news: 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?
> >

>
>
>

 
Reply With Quote
 
Giorgio
Guest
Posts: n/a
 
      02-17-2006
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

 
Reply With Quote
 
bill
Guest
Posts: n/a
 
      02-17-2006

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" <> wrote in message
news: 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do you return to the previous page on cross page postback? YankeeImperialistDog ASP .Net 3 04-28-2009 03:48 PM
View state / postback issues when doing url redirection??? Bob Rock ASP .Net 0 09-17-2006 12:28 PM
Cross Page Posting using public property on previous page =?Utf-8?B?dGhlV2l6YXJkMQ==?= ASP .Net 2 04-20-2006 08:27 PM
How to make a week view and day view calendar just like month view calendar in .NET ? Parthiv Joshi ASP .Net Web Controls 1 07-06-2004 03:15 PM
Go to bookmark using ImageButton and still retain previous content on PostBack Ren ASP .Net 1 04-20-2004 08:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57