New to Telerik UI for ASP.NET AJAX? Download free 30-day trial


The OnValueChanged client-side event handler is called when the user changes the value of the input control. The event occurs immediately after the control loses focus and its value has been updated, but before the server-side TextChanged event.

The OnValueChanged event only occurs if the user entered a valid value that is different from the old value.

Two parameters are passed to the event handler:

  • sender is input control.

  • eventArgs has the following methods:

    • set_cancel() lets you permit or block the postback that occurs when the AutoPostBack property is True. Calling set_cancel(true) prevents the postback.

    • get_oldValue() returns the string value of the input control before the user made any changes.

    • get_newValue() returns the string value that was just assigned to the input control.

The following example uses the OnValueChanged event to prevent a postback if the user entered an empty string:

<telerik:RadTextBox RenderMode="Lightweight" ID="RadTextBox1" runat="server" AutoPostBack="True">
    <ClientEvents OnValueChanged="PreventPostback" />
<script type="text/javascript">
    function PreventPostback(sender, eventArgs)
        if (eventArgs.get_newValue() == "")

See Also

In this article