Social Icons

Monday, 24 June 2013

Hidden Field in Asp.Net

Hidden Field:

ASP.NET allows you to store information in Hidden Field Control, which renders as standard html control on the page. This Hidden Field Control can not be visible in browser. It can be used to store small amount of information which is not secured.
          When a page is submitted to server, content of the hiddenfield is sent in Http form collection along with the values of the other controls. It act as a repository to store any page specific information if you want to store on the page. If a page contains any hidden field then it must be submitted in POST method only.

Advantages of Using Hidden Fields are:

  • No Server resources are required as information is stored in the page.
  • All most all browsers and devices support forms with hidden fields.
  • Simple implementation

Disadvantages of using hidden fields are:

  • Security. Hidden field information is easily tampered if you see the source code of the page.
  • Limited Storage Structure   Hidden field can store single variable value, if you want to store in multiple values you must implement delimited strings and the code to parse strings.
  • Performance. If you try to store large values page will slow down.
Example for Storing values in  Hidden Filed :
  1. Take a form with a hidden field control, label,textbox for taking input and a button control for submittion.


Now in the button click event store the value of textbox in hidden field

 HiddenField1.Value = TextBox1.Text;

If you see the page source after submitting the page then Hidden Field Control renders like this


 
  Hidden Field default value was 0.

Related Tutorials


No comments:

Post a comment

Please Give your Valuable Suggestions,Questions and Comments to improve my blog.