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:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...