什么是MVC3意见输入后显示度量​​单位的好方法? [英] What is a good way to display a unit of measure after inputs in MVC3 views?

查看:119
本文介绍了什么是MVC3意见输入后显示度量​​单位的好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们开发了很多有应该有在他们之后相关的文本标签的度量单位的输入系统。例如平方米,立方公尺,吨英尺立方等我不需要做任何事情一样聪明测量单位之间的规模。只要确保它很容易更新和良好做法。

We develop a lot of systems that have an input that should have a related text label after them for a unit of measure. e.g. Meter square, meter cubed, tonnes, ft cubed etc. I don't need to do anything clever like scale between units of measure. Just ensure that it is easy to update and good practice.

一直在寻找的东西是合理的自动化。结合测量单位的具体属性。我们有超过200个特性混合措施的15个不同单位的屏幕

Was looking for something that is reasonably automatic. That binds the unit of measure to the specific property. We have screens that mix 15 different units of measure with over 200 properties

我用的ViewModels和编辑模板(虽然有些事情很难$ C $光盘作为下拉菜单或texteditorfor等,所以我可以添加类)。

I use ViewModels and Editor templates (although some things are hardcoded as dropdowns or texteditorfor etc so I could add classes).

做任何其他人遇到这个问题?我可能只是很难code在视图中后场的文本。有什么更优雅?也许一个属性等?

Do any other people encounter this issue? I could just hardcode the text after the field in the view. Is there anything more graceful? Maybe an attribute etc?

任何人有最好的方式有什么想法来处理这​​个问题。

Anyone have any thoughts on the best way to handle this.

感谢

推荐答案

使用显示模板和更具体的类型。

Use display templates and more specific types.

有关实例,创建货币这是用来处理货币类。通过这样做,你知道,如果它美分,美元或任何与用户使用的货币。

For instance, create Currency class which is used to handle currencies. By doing so you know if it's cents, dollars or whatever and which currency the user uses.

更多的工作,确保万无一失。但是,code是更强大,更容易地告诉应该用什么单位。

More work, sure. But the code is more robust and it's easier to tell what unit should be used.

这就是为什么使用时间跨度而不是 INT 其中可能包含毫秒,秒等。

That's why are are using TimeSpan and not an int which could contain milliseconds, seconds etc.

这篇关于什么是MVC3意见输入后显示度量​​单位的好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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