getFormattedText();
The getFormattedText method returns formatted text of the component.
The method returns value of the String type.
To execute the example, the page must contain the TextArea components named textArea1 and textArea2 (see Example of Creating the TextArea Component ). Add event handlers for the TextChanged, Blur, Focus events. Next get old text and define new text for the content of the component named textArea1, and also set focus on the two components one after another. Select content of the component named textArea1:
// Handle the TextChanged event textArea1.TextChanged.add(function (sender, eventArgs) { console.log("New contents of the textArea1: " + eventArgs.Value); }); // Handle the Blur event textArea1.Blur.add(function (sender, eventArgs) { console.log("The Blur event is initialized"); }); // Handle the Focus event textArea1.Focus.add(function (sender, eventArgs) { console.log("The Focus is initiated"); }); // Show the text of the textArea1 component contents console.log("Old contents of the textArea1: " + textArea1.getFormattedText()); // Set focus on the textArea1 component textArea1.setFocus(); // Change contents of text area textArea1.setContent("Text area 3"); // Set focus on the textArea2 component textArea2.setFocus(); // Select all contents of the textArea1 component textArea1.selectAll();
After executing the example the textArea1 component contains the text "Text area 3", and its contents is selected:
The browser console displays messages about events initialization, and also old and new text stored in the textArea1 component:
Old contents of textArea1: Text area 1
Focus event initialized
Blur event initialized
New contents of textArea1: Text area 3
See also: