- Using HTML Attributes and DOM Events in the Input Element
- Input DOM Events
Contact Support
Default HTML Attributes and DOM Events
4 Dec 20243 minutes to read
The Syncfusion® ASP.NET Core UI controls provide the most useful public API for control implementation and customization. Apart from this public API, the Syncfusion® ASP.NET Core UI controls can support the use of default HTML attributes in the root element of its control and input DOM events can be applied in the client side.
Using HTML Attributes and DOM Events in the Input Element
The following is a list of Syncfusion® ASP.NET Core UI Controls that use the standard HTML input
element. You can apply the HTML input attributes and DOM events directly to the input element used on these Syncfusion® ASP.NET Core Controls.
- AutoComplete
- CheckBox
- ComboBox
- DatePicker
- DateRangePicker
- DateTimePicker
- DropDownList
- DropDownTree
- MaskedTextBox
- MultiSelect
- NumericTextBox
- RadioButton
- TextBox
- TimePicker
- Upload
- DropDownButton
- ProgressButton
- SplitButton
- InPlaceEditor
- Slider
- Switch
Available Syncfusion® Properties Equivalent to HTML Attributes
The following table illustrates the HTML attributes and their equivalent Syncfusion® API.
HTML Attribute | Syncfusion® API | Controls |
id | ID |
|
autocomplete | Autocomplete |
|
checked | Checked |
|
disabled | Disabled |
|
Enabled |
|
|
max | Max |
|
min | Min |
|
multiple | Multiple |
|
placeholder | Placeholder |
|
readonly | ReadOnly |
|
step | Step |
|
value | Value |
|
width | Width |
|
<ejs-textbox id="textbox" name="first-name" title="First name" autocomplete="Off"></ejs-textbox>
The textbox will be rendered with the following output.
<span class="...">
<input id="textbox" class="..." name="first-name" type="text" autocomplete="off" title="First name" minlength="15" ... />
</span>
In some cases, you may need to add HTML attributes to the root/container element of the above input-based controls. For this, you can use HtmlAttributes Syncfusion® API to add HTML attributes to the root/container element.
@{
IDictionary<string, object> customAttribute = new Dictionary<string, object>()
{
{ "style", "background:aliceblue;" },
};
}
<ejs-textbox id="first" htmlAttributes="customAttribute"></ejs-textbox>
The textbox will be rendered with the following output.
<span class="..." style="background: aliceblue;" ...>
<input id="first" ... />
</span>
Input DOM Events
The Syncfusion® ASP.NET Core UI control supports binding the native DOM events on the input element.
<div class="alert "></div>
<ejs-textbox id="first"></ejs-textbox>
<script>
var input = document.querySelector('.alert');
document.getElementById("first").addEventListener("focus", function () {
input.innerHTML = "Focus event is triggered on the TextBox.";
input.classList.add('alert-info');
});
document.getElementById("first").addEventListener("blur", function () {
input.innerHTML = "Focusout event is triggered on the TextBox.";
input.classList.add('alert-info');
});
</script>