Introduction: In this article I am trying to explain Hidden fields in asp.net with example.
In the previous article I have explained Explain Querystring in asp.net with example, Advantages and Disadvantages of Querystring, Explain cookies in asp.net OR Explain cookies with example in asp.net and Pass multiple variables using Querystring in asp.net .
Hidden field is control in Asp.net or input control. It is used to store small amount of data. The data is store on the client side. It store only one value for variable and is saved as string. It is not visible in browser but can see the stored data by using view source operation of the browser.
<legend>Hidden Field Example</legend>
<tr><td></td><td><asp:HiddenField ID="HiddenField1" runat="server" /></td></tr>
<tr><td></td><td><asp:Button ID="Button1" runat="server" Text="Button"
<tr><td></td><td><asp:Label ID="Label1" runat="server"></asp:Label></td></tr>
Write the below given code on .aspx.cs file(C#):
protected void Page_Load(object sender, EventArgs e)
HiddenField1.Value = "Hidden Field Test";
protected void Button1_Click1(object sender, EventArgs e)
Label1.Text = HiddenField1.Value;
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
HiddenField1.Value = "Hidden Field Test"
Protected Sub Button1_Click1(sender As Object, e As System.EventArgs) Handles Button1.Click
Label1.Text = HiddenField1.Value
1 1. Server resources are not required
2 2. Hidden fields are easy to implement
3 3. All browsers support the hidden filed
1. Hidden fields are not secure because data is stored on client side.
2. Hidden field can store only one value.
3. Hidden field slow down the performance of page if use large number of hidden fields
Is this article helpful for you?
If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.
What do you think about this article?
If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.