数据类型VS UiHint [英] DataType vs UiHint

查看:118
本文介绍了数据类型VS UiHint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用MVC2有一段时间了,而当我需要设置模板,我使用的数据类型属性


  [数据类型(下拉)]
    公众诠释场{搞定;组; }


我看到使用UiHint以达到相同的结果更为


  [UiHint(下拉)]
    公众诠释场{搞定;组; }


什么是使用这两个属性之间的区别?我应该是哪个属性正常使用,或者是他们为不同的任务?


解决方案

数据类型通常被用来让他们知道,这是一个属性的一个非常具体的版本,如价。

数据类型的最常见的例子是 [数据类型(DataTypes.EmailAddress)] 这通常是一个字符串,但我们说这是一种非常特殊的字符串。

他们都乐于助人,UIHint的覆盖的数据类型。所以,如果你有一定的数据类型,但要覆盖你可以使用一个UIHint为特定属性编辑器。

I have been using mvc2 for a while now, and when i need to set the template i use the DataType Attribute

    [DataType("DropDown")]
    public int Field { get; set; }

I see others using UiHint to achieve the same results

    [UiHint("DropDown")]
    public int Field { get; set; }

What is the difference between using these two attributes? Which attribute should I be normally using, or are they for different tasks?

解决方案

DataType is generally used to make it known that this is a very specific version of a property, such as price.

The most common example of DataType is the [DataType(DataTypes.EmailAddress)] which usually is a string but we're saying that this is a very specific type of string.

They're both helpful and the UIHint overrides the DataType. So if you have a certain DataType but you want to override the editor for that specific property you can use a UIHint.

这篇关于数据类型VS UiHint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆