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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add maxlength attribute ?

Thread ID:

Created:

Updated:

Platform:

Replies:

146663 Aug 13,2019 08:40 AM UTC Aug 14,2019 05:20 AM UTC Blazor 1
loading
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.  
 
<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" } }); 
} 
} 
 
 
 
 
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. 
 
<h4>TextBox</h4> 
 
<EjsTextBox HtmlAttributes="@htmlAttribute"></EjsTextBox> 
 
 
@code 
{ 
private Dictionary<string, object> htmlAttribute { get; set; } = new Dictionary<string, object>() { 
            {"maxlength", "12" } 
            }; 
} 
 
 
 
Regards, 
Gopi G. 


CONFIRMATION

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