如何在 ASP.NET MVC 2 中使用 DataType.Custom?
谁能告诉我如何在 ASP.NET MVC 2 中使用 DataType.Custom?
Can anyone tell me how to use DataType.Custom in ASP.NET MVC 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 Brad Wilson 的博客上读过他的 ASP.NET MVC 2 模板系列 此处。它比我更好地解释了你所问的问题。
希望有帮助。
I'd read over Brad Wilson's ASP.NET MVC 2 Template series on his blog here. It explains what you're asking better than I could.
Hope that helps.
我个人没有使用过它,但是查看MSDN,似乎只需设置
DataType = DataType.Custom
和CustomDataType =“String”
即可。然后,当您处理模型时,您将检查 DataType.Custom,如果找到,则根据 CustomDataType 中的值执行不同的操作。以下是他们在 MSDN - 如何:自定义数据字段外观和行为上提供的示例对于数据模型中的非内在数据类型:
I haven't used it personally, but looking at the MSDN it seems to just be a matter of setting
DataType = DataType.Custom
andCustomDataType = "String"
. Then when you process your model you would check for DataType.Custom and if found perform different operations based on the value in CustomDataType.Here's the sample they give on the MSDN - How to: Customize Data Field Appearance and Behavior For Non-Intrinsic Data Types in the Data Model:
不要使用
DataType.Custom
。而是将
[DataType("YourCustomDataTypeHere")]
与名为YourCustomDataTypeHere
的编辑器/显示模板结合使用。Don't use
DataType.Custom
.Instead use
[DataType("YourCustomDataTypeHere")]
with an editor/display template namedYourCustomDataTypeHere
.