Tab

ASPxHiddenField Class

Represents a non visual component to store a set of values and synchronize them between the server and client sides across round trips.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

Declaration

public class ASPxHiddenField :
    ASPxWebComponent,
    IDictionary<string, object>,
    ICollection<KeyValuePair<string, object>>,
    IEnumerable<KeyValuePair<string, object>>,
    IEnumerable

Remarks

The ASPxHiddenField component allows you to transfer values between server and client.

Create a Hidden Field

Design Time

The ASPxHiddenField control is available on the DX.20.2: Components toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize the control's settings, or paste the control markup in the page's source code.

NOTE

To properly function, DevExpress controls require that special modules, handlers and options are registered in the the Web.config file. Switch the Microsoft Visual Studio IDE to the Design tab to automatically update the Web.config file with the required DevExpress information.

<dx:ASPxHiddenField ID="ASPxHiddenField1" ClientInstanceName="hiddenField" runat="server">
</dx:ASPxHiddenField>

Run Time

using DevExpress.Web;
...
protected void Page_Load(object sender, EventArgs e)
{
    ASPxHiddenField hf = new ASPxHiddenField();
    hf.ID = "ASPxHiddenField1";
    Page.Form.Controls.Add(hf);
    hf.ClientInstanceName = "hiddenField";
}
Imports DevExpress.Web
...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim hf As ASPxHiddenField = New ASPxHiddenField()
    hf.ID = "ASPxHiddenField1"
    Page.Form.Controls.Add(hf)
    hf.ClientInstanceName = "hiddenField"
End Sub

Client-Side API

The ASPxHiddenField's client-side API is implemented with JavaScript language and is exposed by the ASPxClientHiddenField object.

Availability

Available by default.

Client object type

ASPxClientHiddenField

Access name

ASPxHiddenField.ClientInstanceName

Events

ASPxHiddenField.ClientSideEvents

NOTE

The client-side API is always available for this control.

Dictionary Storage

The ASPxHiddenField is a dictionary that maintain an unlimited number of elements (key/value pairs). In a key/value pair, a key is a property name (a string) and a value - a property value (an object). Property names (keys) must be unique. Property names can contain any symbols except for the symbols | and # (the vertical bar and the hash sign).

See demo

Supported Value Types

You can store property values of different types in the hidden field.

The hidden field automatically preserves value types and does not require converting values to the required type. It allows you to manipulate the same value type both on the server and client sides.

Learn more

Synchronization

Use the ASPxHiddenField.SyncWithServer property to specify whether the control synchronizes its values between the client and server sides. Synchronization is in effect when either the control sends a postback or callback. Set the ASPxHiddenField.SyncWithServer property to false when you use the hidden field only to pass values from the server to the client. This minimizes data transfer between the client and the server.

NOTE

ASPxHiddenField stores all its content in its own hidden input and does not use ViewState. As a result, the ASPxHiddenField's properties are not automatically available across roundtrips to the client.

Online Demo

ASPxHiddenField - Example

See Also