Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

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 + ".";
    
  }
  
</script>

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

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

<script language="javascript">

  <!--
  function PageLoad()
  {
  
    // Set the value of the HiddenField control with the
    // value from the TextBox.
    Form1.ValueHiddenField.value = Form1.ValueTextBox.value;
    
  }
  -->
  
</script>


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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.