Comapre验证程序在运行时不起作用 [英] Comapre validator is not working at run time

查看:72
本文介绍了Comapre验证程序在运行时不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,如下所示

here is my code which is shown below

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </cc1:ToolkitScriptManager>
    <asp:Label ID="Label1" runat="server" Text="From Date"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="TxtBoxFromDate" runat="server"></asp:TextBox>
    <cc1:CalendarExtender ID="TxtBoxFromDate_CalendarExtender" runat="server"

        Enabled="True" TargetControlID="TxtBoxFromDate" Format="dd/MM/yyyy"

        TodaysDateFormat="dd/MM/yyyy">
    </cc1:CalendarExtender>
    <br />
    <br />
    <asp:Label ID="Label2" runat="server" Text="To Date"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="TxtBoxToDate" runat="server"></asp:TextBox>
    <cc1:CalendarExtender ID="TxtBoxToDate_CalendarExtender" runat="server"

        Enabled="True" TargetControlID="TxtBoxToDate" Format="dd/MM/yyyy"

        TodaysDateFormat="dd/MM/yyyy">
    </cc1:CalendarExtender>
    <br />
    <br />
    <asp:CompareValidator ID="CompareValidator1" runat="server"

        ControlToCompare="TxtBoxToDate" ControlToValidate="TxtBoxFromDate"

        ErrorMessage="CompareValidator" Operator="LessThanEqual" Type="Date"

        ValueToCompare="dd/MM/yyyy">To Date must be greater than From Date</asp:CompareValidator>

    </form>
</body>
</html>

推荐答案

嗨 您写的所有认为都是正确的.对于此问题,您需要将日期格式更改为Format ="yyyy-MM-dd"
Hi You have written all the think is correct. for the problem you need to change your date form as Format="yyyy-MM-dd"
Format="yyyy-MM-dd"




如有任何疑问,请让我知道.

如果有帮助,请提供"投票",如果这是正确的答案,请提供"接受答案".:rose:

谢谢,
Imdadhusen




Please do let me know, if you have any doubt.

Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen


这篇关于Comapre验证程序在运行时不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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