【问题标题】:Display a tooltip with Html helper使用 Html 帮助器显示工具提示
【发布时间】:2015-08-24 14:17:27
【问题描述】:

我想在我的剃刀视图中添加一个工具提示,如下所示:

   @Html.Editor("Password", new { Title = "Doit contenir au moins une lettre majuscule, une minuscule, un chiffre et un caractère spécial" }) 

它不起作用,如果我只是通过输入 html 标签更改 html 帮助器,它就起作用了!!

我需要知道:

  1. 此错误的原因在哪里?
  2. 我该如何解决?

【问题讨论】:

  • Editor 渲染成什么样的元素(这个元素是否支持 Title 属性?)?

标签: html asp.net .net asp.net-mvc razor


【解决方案1】:

使用Html.EditorFor() 添加 html 属性,仅在 MVC-5.1+ 中受支持。如果你确实有 MVC-5.1,那么正确的用法是

@Html.EditorFor(m => m.Password, new { htmlAttributes = new { Title = "Doit contenir ... spécial" }, })

否则,您需要使用@Html.Password()@Html.PasswordFor() 方法

@Html.PasswordFor(m => m.Password, new { Title = "Doit contenir ... spécial"  })

Refer documentation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多