Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想控制或自定义 DisplayFor 和 EditorFor 生成的输出,因此它不会呈现默认的 html css 标签,例如:......
我希望这适用于所有视图,而不仅仅是类型或系统类型?什么是最简单的解决方案?
任何帮助,将不胜感激。
您始终可以创建一个自定义的DisplayFor/EditorFor *.asxc文件,该文件位于其中任何一个中Shared/DisplayTemplates or -/EditorTemplates,将相关类型传递给它,然后只呈现您想要的内容。
Shared/DisplayTemplates or -/EditorTemplates
下面的文章更详细地解释了它:
(这引入了 DisplayFor 方法 - EditorFor 的工作方式完全相同)