When i add an html attribute @id in the the textbox is not rendered in EJ2

Sample code - When i add the @Id attribute, the textbox is not rendered in EJ2. Can you please help?

Current code with @id added:

Generated html:


Please note that if i remove the @id, the textbox is rendered as expected in EJ2. But i need to control the id which is rendered just like when I use Html.TextBoxFor().

Thanks in advance.




1 Reply 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team September 2, 2020 01:40 PM UTC

Hi Support, 

Greetings from Syncfusion support. 

We have validated your reported query.  We suggest you to control the html attribute ID using the HtmlAttributes property of Textbox component. 

@{ 
    IDictionary<string, object> htmlAttr = new Dictionary<string, object>(); 
    htmlAttr.Add("id", "textbox_1"); 
} 
 
@using (Html.BeginForm()) 
{ 
    @Html.ValidationSummary(true) 
    <div id="wrapper"> 
        @Html.EJS().TextBoxFor(model => model.firstname).Placeholder("First Name").HtmlAttributes(htmlAttr).Render() 
        <div> 
            @Html.ValidationMessageFor(model => model.firstname) 
        </div> 
        <div id="submitbutton"> 
            @Html.EJS().Button("btn").Content("Post").Render() 
        </div> 
    </div> 
} 

 


Kindly check with the above sample. Please get back us if you need further assistance. 

Regards, 
Ponmani M 


Marked as answer
Loader.
Up arrow icon