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

ASPxClientTextEdit.GetText Method

Returns the text displayed within the editor.

Declaration

GetText(): string

Returns

Type Description
string

A string value representing the editor’s display text.

Remarks

The GetText method returns a string calculated based on a current editor’s value and the editor’s formatting settings (mask settings, the DisplayFormatString and EditFormatString properties, etc.). In this case, it is required to synchronize a text entered by an end user with an editor’s value before you use the GetText method. For example, if an editor loses focus, the editor automatically calculates (synchronizes) its value based on the entered text.

The GetText method returns an empty value or a previous editor’s text if you call this method before the editor calculates its a new editor’s value. For example, in the client-side UserInput, KeyDown, KeyPress, KeyUp event handlers, this method will return an empty value or a previous editor’s text. In this case, obtain an editor’s text directly from the editor’s input element:

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

See also: Bug Report: ASPxTextBox - The client-side GetText method returns an empty value if a text decoration (for example, a null text) is applied to editor

Example

<dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px" ClientInstanceName="textBox"></dx:ASPxTextBox>
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Set Label Text" AutoPostBack="False" >
    <ClientSideEvents Click="function(s, e) {   label.SetText(textBox.GetText()); }" />
</dx:ASPxButton>
<dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="" ClientInstanceName="label">
</dx:ASPxLabel>

Online Example

See Also