Skip to Main Content
Programming ASP.NET 3.5, 4th Edition
book

Programming ASP.NET 3.5, 4th Edition

by Dan Maharry, Dan Hurwitz, Jesse Liberty
October 2008
Intermediate to advanced content levelIntermediate to advanced
1166 pages
28h 31m
English
O'Reilly Media, Inc.
Content preview from Programming ASP.NET 3.5, 4th Edition

HiddenField Control

Hidden fields are a common trick of the HTML web developer’s trade for carrying information within a page when you do not want that information to be visible to the user—that is, the hidden field provides a way to store state information in the page. For example, you might want to keep track of whether a form on the page has been completed, has been saved as a draft, or is being edited for the first time.

Often, an easier and more elegant way to accomplish this task is to use one of the state mechanisms provided by the .NET Framework (see Chapter 6 for a complete discussion of state). However, sometimes this is impossible, perhaps for performance, bandwidth, or security reasons. (Performance and bandwidth are mostly two sides of the same coin.)

In HTML pages, you might use something such as the following code snippet to implement a hidden field:

<input type="hidden" id="FormStatus" value="Draft Saved">

Indeed, ASP.NET uses a hidden field to implement view state. You can see this by examining the source that is rendered to the browser, via the View → Source menu command in Internet Explorer. (Other browsers have analogous commands.) You will see something similar to the following, where the value attribute encodes all the information saved in view state:

<input type="hidden" name="_  _VIEWSTATE"
   value="/wEPDwUJL0CHlBR...YfL+BDX7xhMw=" />

To reap the benefits of server-side processing, you can use an ASP.NET HiddenField control to generate these hidden fields for use ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Microsoft® ASP.NET 3.5

Programming Microsoft® ASP.NET 3.5

Dino Esposito
Learning ASP.NET 3.5, 2nd Edition

Learning ASP.NET 3.5, 2nd Edition

Brian MacDonald, Dan Hurwitz, Jesse Liberty
Pro ASP.Net 4 in C# 2010

Pro ASP.Net 4 in C# 2010

Matthew MacDonald, Adam Freeman, Mario Szpuszta
Programming .NET 3.5

Programming .NET 3.5

Jesse Liberty, Alex Horovitz

Publisher Resources

ISBN: 9780596156657Supplemental ContentErrata Page