Wednesday, 28 December 2011

Hidden Fields:

Hidden fields: Hidden fields technique is widely used in ASP.NET programing. This is used to store a value that needs to be persisted across posts to the server. Hidden fields are html input control with hidden type that store hidden data in the html. It is rendered as an element. An example for a hidden field can look like this:
< input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
In the example above, I chose to show the event target hidden field in order to indicate that even in postback mechanism hidden fields are being used. The data stored in a hidden field is available when the form is processed on the server or when we use javascript. You can use the HiddenField control to store state values. It can store only one value in their value property. The value is saved as a string and therefore in order to use it for other types you need to perform casting. Hidden field’s data is submitted to the server only in HTTP post operation. You can see the stored data easily by using the View Source operation of the browser. The value of a HiddenField is rendered to the client browser, so it is not suitable for storing security-sensitive values. Be aware not to use hidden fields to store confidential data! The values has page context and therefore when you leave a page the data stored in the hidden fields is disposed.

No comments:

Post a Comment