【问题标题】:take placeholder from resources with html tags使用 html 标签从资源中获取占位符
【发布时间】:2014-12-09 04:58:37
【问题描述】:

我的资源文件中有一个简单的字符串"Good Day,Sir <br /> Have a nice day."。这个字符串必须是 TextArea 上的占位符。但是 html 标签不起作用。我正在尝试使用 Html.Raw 但它没有帮助。应该怎么做我愿意吗?

  @Html.TextAreaFor(model => Model.Text, 15, 5, new { @placeholder = reviewPlaceholder, @class = "span12", @style = "resize: vertical;" })

【问题讨论】:

标签: html asp.net asp.net-placeholder


【解决方案1】:

好吧,虽然规范说用户代理应该从占位符中删除新行,但我在 Chrome 中进行了测试,它接受了新行。您必须将<br /> 替换为/r/n

@Html.TextAreaFor(model => Model.Text, 15, 5, new { @placeholder = reviewPlaceholder.Replace("<br />", "\r\n"), @class = "span12", @style = "resize: vertical;" })

我不能向您保证这将永远有效,因为它不符合规范,但今天它正在工作。

我做了更多测试:适用于所有主要浏览器,但 Firefox 除外。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-13
    • 1970-01-01
    • 2019-10-27
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    • 2013-03-30
    相关资源
    最近更新 更多