How can I use CompareValidator for times without dates?

做~自己de王妃 提交于 2019-11-28 13:57:29
John MacIntyre

This appearently cannot be done.

For the record; I used a custom validator.

EDIT: Here's my custom validator code in case anyone (i.e. alhambraeidos) needs it. Please note, this code replaces my sample control names (txtStart & txtFinish) with actual names from my app (txtReady & txtClose).

try
{
    // parse & compare dates
    string randomDt = "01/01/2000 ";
    args.IsValid = DateTime.Parse(randomDt + txtClose.Text) > DateTime.Parse(randomDt + txtReady.Text);
}
catch(Exception /*ex*/)
{
    // exception is assumed to be invalid times entered
    args.IsValid = false;
}

try to change the Type property to String, it should work.

Compare validator allowable types are: Stinrg, Integer, Double, Date (no time) Currency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!