【问题标题】:MVC 5.2 EditorFor HtmlAttributes Stopped WorkingMVC 5.2 EditorFor HtmlAttributes 停止工作
【发布时间】:2015-02-11 10:45:21
【问题描述】:

我不确定发生了什么变化,但我的 EditorFor 助手上的 htmlAttributes 突然停止工作。标签仍然有效,但 EditorFor 无效。如果我将它们更改为 TextBoxFor 则添加属性/类。

未添加的类:

@Html.EditorFor(model => model.Address1, new { htmlAttributes = new { @class = "textboxXXLg k-textbox" } })

类已添加:

@Html.LabelFor(model => model.Address1, htmlAttributes: new { @class = "control-label ctrl-label required" })

我确认我使用的是 MVC 5.2。

<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />

非常感谢任何帮助。

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-5.2


    【解决方案1】:

    我想通了。我添加了默认的 Kendo 编辑器模板,它们与 EditorFor 冲突。不知道为什么,我没有时间弄清楚。一旦我删除了剑道模板,他们又开始工作了。

    【讨论】:

    • 谢谢,我快疯了。现在我可以继续前进,至少知道它为什么不起作用。
    • 现在的问题是如何正确解决这个冲突。
    • 我最终要做的是将 Kendo 的编辑器模板重命名为 nameKendo.cshtml(例如 StringKendo.schtml),一切正常。如果我真的需要剑道模板,那么我在指向剑道模板的模型属性上使用 UIHint 属性。通过这个技巧(重命名),我们可以避免冲突。有没有cmets?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 1970-01-01
    • 2020-05-10
    • 1970-01-01
    • 2011-09-14
    • 1970-01-01
    • 2016-08-16
    相关资源
    最近更新 更多