Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

Using hidden form fields to preserve state

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 17 Feb 2006 14:38 GMT
Assume you have a web application with many different web pages, and you'd
like to avoid using cookies and storing session state in any form.  Assume
further that bandwidth and security are not issues.

Could you conceivably store a serialized object containing state information
in a hidden form field, and pass it from page to page to page avoiding the
use of cookies and session data?

Thanks.

Mark
McGeeky - 17 Feb 2006 14:49 GMT
I was involved in a Java project that used this technique way back in 2000.
We serialized our objects in to XML, embedded them in a hidden form field,
and then desieralized when the page got posted.

The downside was that it meant the code behind every page having to do extra
work, also meant the pages could be quite big.

Upside was that there was no state stored in the session.

Signature

McGeeky
http://mcgeeky.blogspot.com

> Assume you have a web application with many different web pages, and you'd
> like to avoid using cookies and storing session state in any form.  Assume
[quoted text clipped - 7 lines]
>
> Mark
Darren Kopp - 17 Feb 2006 16:52 GMT
Yes it's possible, just make sure that all your objects are
serializable ([Serializable] attribute on all custom classes, then call
the serialize method).  You will also need to get the data from the
field on the next page through Request.Form["key"] i believe.

HTH,
Darren Kopp
http://blog.secudocs.com/
Steven Cheng[MSFT] - 20 Feb 2006 02:12 GMT
Hi Mark,

As other members have mentioned, you can use html hidden form fields to
store some string data or serialized objects' content. However, for posting
from page to page ...., this is difficult. Are you using ASP.NET 2.0? If
so, it support cross page posting, however, this still require us to do
POST between pages so that the html form fields can be passed from original
page to target page.

Regards,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Eliyahu Goldin - 19 Feb 2006 09:48 GMT
Mark,

You will want to use hidden fields only if the information you are putting
there is needed on the client side too. Otherwise you should use ViewState
as an alternative to session variables.

What do you mean by "passing from page to page"? From page A to page B, or
between the postbacks for the same page? If from page A to page B, do you
want to pass object on client side or on server side? If on server side,
hidden fields won't help you.

Eliyahu

> Assume you have a web application with many different web pages, and you'd
> like to avoid using cookies and storing session state in any form.  Assume
[quoted text clipped - 7 lines]
>
> Mark

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.