Saturday, July 10, 2010

How to implement date range validator - Asp.net

<%@ Page Language="C#" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <asp:TextBox ID="Txtfrom" runat="server" CssClass="dataField" Width="120px"></asp:TextBox>
        <asp:calendarextender id="Txtfrom_CalendarExtender" runat="server" enabled="True"
             targetcontrolid="Txtfrom"
             cleartime="True" 
             todaysdateformat="dd/MM/yyyy" 
             format="dd/MM/yyyy" />
        <asp:TextBox 
             ID="Txtto" 
             runat="server" 
             CssClass="dataField" />
        <asp:calendarextender
            id="Txtto_CalendarExtender" 
            runat="server" 
            enabled="True" 
            targetcontrolid="Txtto"
            format="dd/MM/yyyy" 
            todaysdateformat="dd/MM/yyyy" />
        <asp:CompareValidator 
            ID="CompareValidator2" 
            runat="server" 
            ControlToCompare="Txtfrom"
            ControlToValidate="Txtto" 
            ErrorMessage="from date should not greater then to date"
            Operator="GreaterThan" 
            Type="Date" />
         <asp:Button runat="server" ID="btnPostback" Text="Postback" />
    </div>
    </form>
</body>
</html>

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...