Sounds like a very good suggestion Scott.
I can see how a lot of problems would be avoided.
I will do that for any new work ahead. For now I must deal with some
extensive existing work that at the moment does not allow the time for a
nearly complete re-write.
Many thanks for that point of view...
Is there any mechanism other than Session variables that I might use to
transfer the data in conjunction with a Response.Redirect?
Actually is Response.Redirect the accepted and standard way to move from
page to page after using standard postback? I would think that method would
be clearly stated in almost all Beginning ASP.NET books or tutorials. Most
examples show how server controls are used in a simple postback and don't
even bother to cover the topic of moving "state" data (or any other data)
between pages.
Can someone point me to a tutorial spcifically covering those fundamentals?
I have reviewed a complete chapter on Maintaining State in a Wrox
Professional ASP.NET book and realize they spend more time on mind deadening
theory than actual practice.
> Is there any mechanism other than Session variables that I might use to
> transfer the data in conjunction with a Response.Redirect?
Well, there is the Application cache and static variables, but if you use
those you'll need to implement some mechanism for keeping each user's data
separate as well as "cleaning up" after yourself. If you're using a
cross-page postback (meaning the search form actually posts to the results
form instead of using a Response.Redirect in the code-behind of the search
form) then you can use POST data - see below.
> Actually is Response.Redirect the accepted and standard way to move from
> page to page after using standard postback? I would think that method
> would be clearly stated in almost all Beginning ASP.NET books or
> tutorials. Most examples show how server controls are used in a simple
> postback and don't even bother to cover the topic of moving "state" data
> (or any other data) between pages.
Response.Redirect, as far as I know, is the accepted standard. The reason
you don't see anything about moving "state" between pages is that it's not
standard and it's not "easy".
When working with cross-page postbacks you pretty much get the POST data and
nothing else. And you have to use Request.Form or Request.Params to get at
those, I believe. If the viewstate *is* posted to the new page (it is just a
hidden form field, after all) I think you'll have to decode it and parse it
yourself. I've never gone down that path, so I'm probably not the best guy
to be giving advice here. Just trying to give you some things to look into.
Try setting a breakpoint in the destination page and checking
"Request.Params" to see what you're given. Maybe you'll find enough in there
to solve your problem.
John Kotuby - 12 Dec 2007 16:34 GMT
Scott,
Thank you so much for taking the time to anwer my questions. Now I undestand
that the Viewstate is used during a simple post-back which makes accessing
the contents of Server controls very easy, even if they are nested several
levels deep in User controls. I guess it also allows user-made changes to
the page to persist if the page is re-displayed.
I understand that most of the control values can be accessed at the
Page_Load event. I have heard that the results of other server-side events
(such as the SelectedIndexChanged ) must be accessed later on in the page
life-cycle like at the Page_PreRender stage.
Your insight is very useful to me.
Wishing you the best...
>> Is there any mechanism other than Session variables that I might use to
>> transfer the data in conjunction with a Response.Redirect?
[quoted text clipped - 26 lines]
> checking "Request.Params" to see what you're given. Maybe you'll find
> enough in there to solve your problem.