asp.net.ph

Skip Navigation Links

Adding HiddenField Controls to a Web Forms Page

Controls You Can Use on Web Forms   ASP.NET Standard Controls   HiddenField Control


To use a HiddenField Web server control, you add it to a page and then add controls and static text to it.

To add a HiddenField control to a Web Forms page

  1. Declare an <asp:HiddenField> element on the page. For syntax, see HiddenField Control Syntax.
  2. Optionally set the following properties of the HiddenField control to specify how the hiddenfield interacts with its child controls.

Property Description
HorizontalAlign Specifies how the child controls are aligned within the hiddenfield ( left, right, center, or justified ).
Wrap Specifies whether content that is too wide for the hiddenfield is wrapped to the next line or truncated at the hiddenfield’s edge.
  1. Optionally set the HiddenField's style attributes to create a distinct appearance for the group of controls within the hiddenfield.
<asp:HiddenField id="myHiddenField" backcolor="wheat" width=300 
   borderstyle="ridge" borderwidth=1 runat="server">

The following example shows how you can dynamically add controls to a HiddenField control at run time.

HiddenField1.aspx
Run Sample | View Source

For details about adding controls to a container control such as a HiddenField, see Adding Controls to a Web Forms Page Programmatically.

See Also

Introduction to the HiddenField Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note