You can store page-specific information in a hidden field on your page as a way of maintaining the state of your page.If you use hidden fields, it is best to store only small amounts of frequently changed data on the client.
ASP.NET allows you to store information in a HiddenField control, which renders as a standard HTML hidden field. A hidden field does not render visibly in the browser, but you can set its properties just as you can with a standard control. When a page is submitted to the server, the content of a hidden field is sent in the HTTP form collection along with the values of other controls. A hidden field acts as a repository for any page-specific information that you want to store directly in the page.
Advantages of using hidden fields are:
- No server resources are required : The hidden field is stored and read from the page.
- Widespread support Almost all browsers and client devices support forms with hidden fields.
- Simple implementation Hidden fields are standard HTML controls that require no complex programming logic.
Disadvantages of using hidden fields are:
- Potential security risks : The hidden field can be tampered with. The information in the hidden field can be seen if the page output source is viewed directly, creating a potential security issue. You can manually encrypt and decrypt the contents of a hidden field, but doing so requires extra coding and overhead. If security is a concern, consider using a server-based state mechanism so that no sensitive information is sent to the client.
- Simple storage architecture : The hidden field does not support rich data types. Hidden fields offer a single string value field in which to place information. To store multiple values, you must implement delimited strings and the code to parse those strings. You can manually serialize and de-serialize rich data types to and from hidden fields, respectively. However, it requires extra code to do so. If you need to store rich data types on the client, consider using view state instead. View state has serialization built-in, and it stores data in hidden fields.
- Performance considerations:Because hidden fields are stored in the page itself, storing large values can cause the page to slow down when users display it and when they post it.
- Storage limitations:If the amount of data in a hidden field becomes very large, some proxies and firewalls will prevent access to the page that contains them. Because the maximum amount can vary with different firewall and proxy implementations, large hidden fields can be sporadically problematic.
You have to understand the advantages and disadvantages before working on HiddenField so that program will remain in your court because it is one of the important concept under State Management in ASP.NET.
Find out positive reviews received by SynapseIndia for website development.
SynapseIndia’s CEO Shamit Khemka says that employees at SynapseIndia work with motto to provide client satisfaction without giving them any chance to complaints in any cases.