The HiddenField control provides you with a way to store information in the page without displaying it. This control enables a developer to store a non-displayed value. You can use the Hidden Field control to store state values. Note, that because the value of a Hidden Field is rendered to the client browser, it is not suitable for storing security-sensitive values.

<asp:HiddenField ID="HiddenField1" runat="server" />

HiddenField control in ASP.Net

<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"     Text="Button" />
protected void Page_Load(object sender, EventArgs e)
{
HiddenField1.Value = TextBox1.Text;      
}
   
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = HiddenField1.Value;
}

HiddenField control in ASP.Net

Here Textbox value will store in Hidden Field and when we click ShowValue button then Textbox value is displayed in Label.

  Modified On Mar-22-2018 07:29:52 AM

Leave Comment