<h4>TextBox</h4>
<EjsTextBox @ref="TextBoxObj"></EjsTextBox>
<button class="e-btn" @onclick="Clicked">Add Attributes</button>
@code
{
EjsTextBox TextBoxObj;
public void Clicked()
{
TextBoxObj.AddAttributes(new Dictionary<string, object>() { { "maxlength", "12" } });
}
}
|
<h4>TextBox</h4>
<EjsTextBox HtmlAttributes="@htmlAttribute"></EjsTextBox>
@code
{
private Dictionary<string, object> htmlAttribute { get; set; } = new Dictionary<string, object>() {
{"maxlength", "12" }
};
} |
Buen día, también funcionaria para agregar el atributo maxlength al control SfAutocomplete ??
Hi Milton,
You can also use the maxlength in the autocomplete component also by using the htmlattributes property.
Find the code example here:
<SfAutoComplete TValue="string" TItem="Colors" HtmlAttributes="@htmlAttribute" Autofill=true PopupHeight="230px" Placeholder="Select a color" DataSource="@ColorsData"> <AutoCompleteFieldSettings Value="Color"></AutoCompleteFieldSettings> </SfAutoComplete> @code { private Dictionary<string, object> htmlAttribute { get; set; } = new Dictionary<string, object>() { {"maxlength", "6" } }; public class Colors { public string Code { get; set; } public string Color { get; set; } } private ObservableCollection<Colors> ColorsData = new ObservableCollection<Colors>() { new Colors() { Color = "Chocolate", Code = "#75523C" }, new Colors() { Color = "CadetBlue", Code = "#3B8289" }, new Colors() { Color = "DarkOrange", Code = "#FF843D" }, new Colors() { Color = "DarkRed", Code = "#CA3832"}, new Colors() { Color = "Fuchsia", Code = "#D44FA3" } }; }
|
Regards,
Sureshkumar P