HI WELCOME TO KANSIRIS

Hidden Field in Asp.Net

Leave a Comment

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.
- See more at: http://www.aspdotnet-sekhar.com/2013/06/hidden-field-in-aspnet.html#sthash.o7VHd98r.dpuf

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.