如何在时间选择器上使用比较验证器。 [英] How to use a compare validator on time selector.

查看:73
本文介绍了如何在时间选择器上使用比较验证器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里使用MKB时间选择器是我的aspx代码。我想要进行验证,以便结束时间不应小于开始时间。任何帮助都将不胜感激。



I am using a MKB time selector here is the my aspx code.I want put a validation so that end time should not be less than the start time.Any help would be appreciated.

<MKB:TimeSelector ID="TimeSelector2"  runat="server" SelectedTimeFormat="Twelve" 

             AmPm="PM" BorderColor="Silver" Date="" Hour="0" Minute="0" Second="0">
         <MKB:TimeSelector ID="TimeSelector1"  runat="server" Date="" Hour="0">

推荐答案

HI,



让我们假设你得到的值是1. 03:15,2。04:20



在后面的代码中获取两个值并将它们存储在2个不同的整数变量中,如 a = 0315 b = 0420



现在您将两个值作为两个整数,您可以比较自己的值在简单的 if(a> b)语句中。



将限制和验证消息放在条件语句中如你所愿。



请记住,这不是完成任务的最终方式。您可以通过更多方式实现这一目标。我立即想到了这个想法,所以我认为它可能会告诉你一种方法。



谢谢


Lets assume you are getting the values as 1. "03:15", 2. "04:20".

In the code behind get the two values and store them in 2 different integer variables like a=0315, b=0420.

Now you got the two values as the two integers and you can compare the values of your own in simple if(a>b) statement.

Put the restrictions and validation messages with in the conditional statements as you want.

Remember this is not the ultimate way of doing the task. You can do it in many more ways. This idea came to my mind instantly so I thought it might show you a way to approach.

Thanks


这篇关于如何在时间选择器上使用比较验证器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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