Skip to main content
A newer version of this page is available. .

ASPxClientTextEdit.KeyPress Event

Occurs on the client-side when an end-user presses and releases a key while the editor has focus.

Declaration

KeyPress: ASPxClientEvent<ASPxClientEditKeyEventHandler<ASPxClientTextEdit>>

Event Data

The KeyPress event's data class is ASPxClientEditKeyEventArgs. The following properties provide information specific to this event:

Property Description
htmlEvent Gets a DHTML event object that relates to the processed event.

Remarks

The editors’ client-side functionality provides the ability to respond to key presses and releases made by end users. Each time an end-user presses and releases a key while an editor has focus, the KeyPress event fires. This event can be handled to implement custom processing of a key being pressed and released.

Using the ASPxClientEditKeyEventArgs.htmlEvent property of the event’s argument, you can obtain the necessary information related to the pressed key (such as its key code, the modifier key pressed, etc).

The GetText and the GetValue methods can return an incorrect (empty or previous) value in the client-side UserInput, KeyDown, KeyPress, and KeyUp event handlers when you apply a format, mask, or null text settings to a text editor.

In this case, obtain the editor’s text from the editor’s input element:

function OnKeyPress(s, e) {  
    var currentText = s.GetInputElement().value;  
}

For more information refer to the following Support Center ticket: ticket.

Example

This example demonstrates how the default browser processing of the Enter key, pressed while an ASPxTextBox has input focus, can be canceled with the help of a specific client method of a service ASPxClientUtils client object.

Note that the client script implementing the ASPxClientUtils object should be explicitly registered, to make this object available on the client:

protected void Page_Load(object sender, EventArgs e){
    DevExpress.Web.ASPxWebControl.RegisterBaseScript(Page);
}
See Also