We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add maxlength attribute ?

Thread ID:





146663 Aug 13,2019 08:40 AM UTC Aug 14,2019 05:20 AM UTC Blazor 1
Tags: TextBox
Mr Andrey Voronov
Asked On August 13, 2019 08:40 AM UTC

Its not clear how to use AddAttributes method because it accept object parameter.

Gopi Govindasamy [Syncfusion]
Replied On August 14, 2019 05:20 AM UTC

Hi Andrey Voronov, 
Greetings from Syncfusion support. 
The AddAttributes method  is used to add multiple attributes depending on the key-value pair to the input element of the textbox. So you can add the maxlength attributes using Dictionary type. We have prepared sample based on your requirement. Please find the code snippet and sample for your reference.  
<EjsTextBox @ref="TextBoxObj"></EjsTextBox> 
<button class="e-btn" @onclick="Clicked">Add Attributes</button> 
EjsTextBox TextBoxObj; 
public void Clicked() 
    TextBoxObj.AddAttributes(new Dictionary<string, object>() { { "maxlength", "12" } }); 
We would like to inform you that we have provided HtmlAttributes. By default, the HtmlAttributes property is available in Textbox. You can add the custom attribute to the textbox input element by using this property. 
The following code example demonstrates how to set the custom attribute to the textbox component using HtmlAttributes property. 
<EjsTextBox HtmlAttributes="@htmlAttribute"></EjsTextBox> 
private Dictionary<string, object> htmlAttribute { get; set; } = new Dictionary<string, object>() { 
            {"maxlength", "12" } 
Gopi G. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon