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

HiddenField Control in ASP.Net


ASP.Net ASP.Net 
Ratings:
0 Comment(s)
 9683  View(s)
Rate this:

HiddenField control in ASP.Net

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.


Don't want to miss updates? Please click the below button!

Follow MindStick