- FocusIn method
- FocusOut method
- GetPersistData method
Contact Support
Methods in ASP.NET MVC TextArea Control
22 Mar 20243 minutes to read
This section outlines the methods available for interacting with the TextArea control.
FocusIn method
The focusIn method in the TextArea, is used to set focus to the textarea element, enabling user interaction.
By calling the focusIn
method, you can programmatically set focus to the TextArea control, allowing users to interact with it via keyboard input or other means.
<div class="control-section">
<div class="control_wrapper textarea-control-section">
@Html.EJS().TextArea("default").Render()
<button id="button">Focus-in</button>
</div>
</div>
<script>
document.getElementById("button").onclick = function() {
var textareaObj = document.getElementById('default').ej2_instances[0];
textareaObj.focusIn();
};
</script>
public ActionResult Methods1()
{
return View();
}
FocusOut method
The focusOut method in the TextArea control is used to remove focus from the textarea element, ending user interaction.
This method is beneficial for scenarios where user need to programmatically remove focus from the TextArea control, such as after completing a specific task or when navigating to another element in the application.
<div class="control-section">
<div class="control_wrapper textarea-control-section">
@Html.EJS().TextArea("default").Render()
<button id="button">Focus-Out</button>
</div>
</div>
<script>
document.getElementById("button").onclick = function() {
var textareaObj = document.getElementById('default').ej2_instances[0];
textareaObj.focusOut();
};
</script>
public ActionResult Methods2()
{
return View();
}
GetPersistData method
The getPersistData method in the TextArea control retrieves the properties that need to be maintained in the persisted state.
This method returns an object containing the properties to be persisted, which can include various configuration options and state information of the TextArea control.
<div class="control-section">
<div class="control_wrapper textarea-control-section">
@Html.EJS().TextArea("default").Render()
<button id="button">Get Persisit-data</button>
</div>
</div>
<script>
document.getElementById("button").onclick = function() {
var textareaObj = document.getElementById('default').ej2_instances[0];
textareaObj.getPersistData();
};
</script>
public ActionResult Methods3()
{
return View();
}