asp.net - 带有 DisplayNameFor 的 Display 属性中的 ASP MVC 不间断空格

标签 asp.net asp.net-mvc displayattribute

我有一个带有属性“Price”的模型,其中包含 DisplayAttribute

[Display(Name = "Price (in €)")]

现在我想使用在表头中显示它

@Html.DisplayNameFor(model => model.Price)

但是当列非常小时,文本可能会分成两行:

Price (in
€)

但我希望它能这样打破:

Price
(in €)

是否可以在 Display 属性中插入不间断空格? 使用“价格(单位:欧元)”会导致“ ”打印为文本。

最佳答案

Andrei 在评论中发布了正确的答案: 不间断空格是一个 unicode 字符,代码为 00a0。所以这应该有效:

[Display(Name = "Price (in\u00a0€)")]

关于asp.net - 带有 DisplayNameFor 的 Display 属性中的 ASP MVC 不间断空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26844652/

相关文章:

C# .NET 如何在不使用 StringBuilder.ToString() 的情况下将 StringBuilder 转换为字节数组

c# - ASP.Net MVC 6 身份验证和授权

asp.net-mvc - 使用代码迁移更新 MVC 模型

c# - 找不到命名空间名称 'Display' 和 'DisplayAttribute'

c# - 从外部域 (AWS S3) 加载图像并将其存储在浏览器内存中

.net - 我的服务器上有两个machine.config文件,我该编辑哪个文件,以及如何验证它们是否正在使用?

html - 是完全不渲染 HTML 更好,还是添加显示 :none? 更好

asp.net - Asp.net的表单认证

asp.net - 自动转义 Asp.Net MVC