Export (0) Print
Expand All

HiddenField.ValueChanged Event

Note: This event is new in the .NET Framework version 2.0.

Occurs when the value of the HiddenField control changes between posts to the server.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public event EventHandler ValueChanged
/** @event */
public void add_ValueChanged (EventHandler value)

/** @event */
public void remove_ValueChanged (EventHandler value)

JScript supports the use of events, but not the declaration of new ones.

The ValueChanged event is raised when the value of the HiddenField control changes between posts to the server. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.

For more information about handling events, see Consuming Events.

The following example demonstrates how to use the ValueChanged event to display the value of the HiddenField control.

<%@ Page language="C#" %>

<script runat="server">
  void ValueHiddenField_ValueChanged (Object sender, EventArgs e)
    // Display the value of the HiddenField control.
    Message.Text = "The value of the HiddenField control is " + ValueHiddenField.Value + ".";

        <form id="Form1" runat="server">
            <h3>HiddenField Example</h3>

            Please enter a value and click the submit button.<br/>
            <asp:Textbox id="ValueTextBox"
            <input type="submit" name="SubmitButton"
             onclick="PageLoad()" />
            <asp:label id="Message" runat="server"/>    
            <asp:hiddenfield id="ValueHiddenField"

<script language="javascript">

  function PageLoad()
    // Set the value of the HiddenField control with the
    // value from the TextBox.
    Form1.ValueHiddenField.value = Form1.ValueTextBox.value;

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft