Wednesday, 6 July 2016

Hiddenfield



1.What are Hidden Fields?
Hidden fields technique is widely used in ASP.NET programing. Hidden fields are html input control with hidden type that store hidden data in the html. 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.

2. Hidden Fields Values

Hidden fields 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 fields' 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. You can see it by clicking the right mouse button and then choosing View Source from the menu (if the operation is available). 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.





3. What is Hiddenfield and what are advantages and disadvantages of Hiddenfield?




Hidden fields are used to store data at the page level. These fields are not rendered by the browser. It's just like a standard control for which you can set its properties. Whenever a page is submitted to server, hidden fields values are also posted to server along with other controls on the page.

Ex:
//To Set Value
Hidden1.Value="Set Value Here";
//to retrieve a value
string strGetValue = Hidden1.Value;

Simple to implement and store small amout of data so they take less size.
These won't fit for sensitive data and values can be clearly visisble when passing through the network.


No comments:

Post a Comment