Telerik overriding htmlattributes?

6 posts, 0 answers
  1. Brent
    Brent avatar
    7 posts
    Member since:
    Apr 2015

    Posted 26 Feb Link to this post

    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?

  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 01 Mar Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Brent
    Brent avatar
    7 posts
    Member since:
    Apr 2015

    Posted 01 Mar in reply to Ianko Link to this post

    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
  5. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 02 Mar Link to this post

    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
  6. Brent
    Brent avatar
    7 posts
    Member since:
    Apr 2015

    Posted 02 Mar in reply to Ianko Link to this post

    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."
  7. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 04 Mar Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready