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. For more information, see ASP.NET Web Application Security and Basic Security Practices for Web Applications.
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. If you need to store many items of data, consider doing one of the following:
Put each item in a separate hidden field.
Use view state with view-state chunking turned on, which automatically separates data into multiple hidden fields.
Instead of storing data on the client, persist the data on the server. The more data you send to the client, the slower the apparent response time of your application will be because the browser will need to download or send more data.
a. Easy to implement
b. Hidden fields are supported by all browsers
c. Enables faster access of information because data is stored on client side
a. Not secure because the data is stored on Client side.
b. Decreases page performance if too many hidden fields
c. Only support single value.
Rate this answer
51 votes , average 5 out of 5
Back to asp.net interview questions