This is a migrated thread and some comments may be shown as answers.

Telerik overriding htmlattributes?

5 Answers 402 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brent
Top achievements
Rank 2
Brent asked on 26 Feb 2016, 09:49 PM

I have an existing .NET MVC app where I upgraded it to a Telerik MVC app, and I'm noticing my controls htmlattributes are being overridden it seems.

In my view I have controls like this:

@Html.EditorFor(model => model.CompanyName, new {htmlAttributes = new {@class = "form-control", required = "true"}})

which would previously render like:

<input name="CompanyName" class="form-control text-box single-line" id="CompanyName" required="true" type="text" value="" data-val="true" data-val-length-max="50" data-val-length="50 characters max">

Now with Telerik, they render like this:

<input name="CompanyName" class="k-textbox" id="CompanyName" data-val="true" data-val-length-max="50" data-val-length="50 characters max">

You can see I'm losing my form-control, etc classes, and the required attribute. What is overriding this and how should I handle this?

5 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 01 Mar 2016, 11:34 AM
Hi Brent,

Thank you for reaching out to us. 

I assume that with upgrading to Telerik MVC App, the "Add Editor Templates" option has been checked. Thus, the templates have included. Which are extended with Kendo Extensions for the base types.

You can check in the Shared views if there is an EditorTemplates folder. By deleting this folder the templates will be removed and the native templates will be rendered when using EditorFor method.

If, however, you are interested in examining and updating this templates, you can adjust them by opening the file corresponding to the base type to be edito. In the case here, I guess it is the String.cshtml file.

Let me know if I can be any further helpful on the case.

Regards,
Ianko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Brent
Top achievements
Rank 2
answered on 01 Mar 2016, 04:29 PM
Thanks, That was it. You might want to add a note about this to the upgrade section of the docs located at http://docs.telerik.com/kendo-ui/aspnet-mvc/vs-integration/convert-project-wizard
0
Ianko
Telerik team
answered on 02 Mar 2016, 09:10 AM
Hi Brent,

The information about the EditorTemplates is included in this article: 

You can modify the following project-wide settings:
...
  • Copy Editor Templates - Copy the predefined editor templates to ~/Views/Shared/EditorTemplates
...

Regards,
Ianko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Brent
Top achievements
Rank 2
answered on 02 Mar 2016, 03:05 PM
I saw that. I meant a note added on to this saying something along the lines of "Note: These will override any existing styles and attributes on your existing controls when you upgrade your project."
0
Alex Gyoshev
Telerik team
answered on 04 Mar 2016, 09:23 AM

Hello Brent,

Thank you for the suggestion. We have forwarded your feedback to the development team.

Regards,
Alex Gyoshev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Brent
Top achievements
Rank 2
Answers by
Ianko
Telerik team
Brent
Top achievements
Rank 2
Alex Gyoshev
Telerik team
Share this question
or