Html.DisplayFor加引号中的文字? [英] Html.DisplayFor adds text in quotes?
问题描述
如果我加入一些code是这样的:
If I add some code like this:
<div>
@Html.DisplayFor(x => x.SomeTextField)
</div>
...它将呈现像这样...
...it is rendered like so...
<div>
"
SomeTextFieldsValue
"
</div>
这因为它不使用标签,因为我本来期望......比方说,一个标签标签是奇怪的。
This is strange as it isn't using a tag as I would have expected... say, a label tag.
什么是在HTML这种使用双引号。难道简写标记?
What is this use of double quotes in the html. Is it shorthand for a tag?
这是很难通过谷歌搜索来寻找答案。
It's hard to find an answer by googling.
我问这个问题了一会儿前,它很快就被标记为preVIOUSLY回答了这个线程(由理查德·埃弗雷特,Reniuz,Soner格尼尔):
I ASKED THIS QUESTION A MOMENT AGO AND IT QUICKLY GOT MARKED AS PREVIOUSLY ANSWERED BY THIS THREAD (by Richard Everett, Reniuz, Soner Gönül):
请再次做同样的前阅读我的问题,你会看到它是不一样的问题呢?
Please read my question before doing the same again and you will see IT IS NOT the same question at all?
推荐答案
为字符串使用
不生成的HTML加上双引号。 DisplayFor
默认显示模板
The default display template used by DisplayFor
for a string
doesn't add double quotes in the generated HTML.
所以我看到两种可能性:
So I see two possibilities:
-
SomeTextField
价值包含这些双引号 - 您必须在您的项目自定义的
DisplayTemplate
为SomeTextField
的类型(我假设字符串
),增加了他们
- Value of
SomeTextField
contains those double quotes - You have in your project a custom
DisplayTemplate
for the type ofSomeTextField
(I assumestring
) that adds them
这篇关于Html.DisplayFor加引号中的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!