使用MVC万全验证PassOnNull - 可空或QUOT; 01.01.0001 00:00:00" [英] MVC Foolproof Validation using PassOnNull - Nullable or "01.01.0001 00:00:00"

查看:164
本文介绍了使用MVC万全验证PassOnNull - 可空或QUOT; 01.01.0001 00:00:00"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试tovalidate两个日期(开始 - >结束),其中仅第一IST必要,但是当用户进入第二日起必须大于第一。我使用MVC万全包的PassOnNull参数。

I try tovalidate two dates (start -> end) where only the first ist required, but when the user enters the second date it must be greater than the first. I'm using the MVC Foolproof package with the "PassOnNull" parameter.

型号

<Required()> _
<DisplayName("Event Start")> _
<DataType(DataType.DateTime)> _
'This doesn't work:
Public Property EventStart As Nullable(Of DateTime)
'This does work but with the ugly default value in the textbox
Public Property EventStart As DateTime

<DisplayName("Event End")> _
<DataType(DataType.DateTime)> _
<GreaterThan("EventStart", PassOnNull:=True)> _
Public Property EventEnd As Nullable(Of DateTime)

我可以得到它与设置EventStart日期无法正常工作不会为空的,但后来我得到值为01.01.0001 00:00:00,这是一个文本框默认日期 NT甚至我的乡土风情!

I can get it to work with setting the EventStart date not NOT nullable but then i get a default date in the textbox with the value "01.01.0001 00:00:00" which is'nt even my country setting!

所以,我想获得它与可空模型属性格式工作或摆脱01.01.0001 00:00:00的价值,并有一个空白,而不是textboy!

So I would like to get it to work with the nullable model propery or get rid of the "01.01.0001 00:00:00" value and have a blank textboy instead!

推荐答案

好吧看完之后 HTTP: //foolproof.$c$cplex.com/discussions/220498 在codePLEX我现在知道它倒过来:

Ok after reading http://foolproof.codeplex.com/discussions/220498 on Codeplex I now know it works the other way round:

<Required()> _
<DisplayName("Event Start")> _
<LessThan("EventEnd", PassOnNull:=True)> _
Public Property EventStart As Nullable(Of DateTime)

<DisplayName("Event End")> _
Public Property EventEnd As Nullable(Of DateTime)

这篇关于使用MVC万全验证PassOnNull - 可空或QUOT; 01.01.0001 00:00:00&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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