articles

Home / DeveloperSection / Articles / HiddenField Control in ASP.Net

HiddenField Control in ASP.Net

Pushpendra Singh 17019 19-Oct-2010

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.


Updated 07-Sep-2019

Leave Comment

Comments

Liked By