MVC中UIHint属性有什么用
谁能解释一下 MVC 中 UIHint 属性的用途是什么。为什么我们需要这个。以及何时以及如何使用。谢谢
Can anyone please explain me what is the use of UIHint attribute in MVC . Why do we need this. and when and how to use . Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIHintAttribute 指定动态数据用于显示数据字段。
这是 UIHintAttribute 的 MSDN 描述。它首先是针对动态数据应用程序引入的,ASP.NET MVC 也对其进行了改编。
如果您使用 UIHint 属性注释属性并在视图中使用
EditorFor
或DisplayFor
,ASP.NET MVC 框架将查找您通过UIHintAttribute 指定的指定模板
。它查找的目录是:对于
EditorFor
:对于
DisplayFor :
如果您位于某个区域,它也适用于您的区域,如上所示。
以下是使用示例:
如果您尝试使用
EditorFor
或DisplayForpoo
的分部视图代码>如下所示:UIHintAttribute Specifies the template or user control that Dynamic Data uses to display a data field.
This is the MSDN description of UIHintAttribute. It firstly introduced for Dynamic Data applications and ASP.NET MVC also adapted it.
If you annotate a property with UIHint attribute and use
EditorFor
orDisplayFor
inside your views, ASP.NET MVC framework will look for the specified template which you specified throughUIHintAttribute
. The directories it looks for is:For
EditorFor
:For
DisplayFor
:If you are on an area, it applies to your area like above as well.
Here is the usage sample:
MVC framework will look for partial view named
poo
under the specified directories if you try to output the model property withEditorFor
orDisplayFor
like below: