Wednesday, December 29, 2010

From Date -To Date with validation and Ajax in asp.net

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<table align="center" cellpadding="3" cellspacing="2" width="75%">
 <tr bgcolor="#7DBEFF">
   <td> <asp:Label ID="Label1" runat="server" Text="From Date"      
         CssClass="bold"></asp:Label>                    
                        
   </td>
   <td>                       
        <asp:TextBox ID="txt_from" runat="server"></asp:TextBox>
        <cc1:TextBoxWatermarkExtender ID="txt_from_TextBoxWatermarkExtender"
          runat="server" Enabled="True" TargetControlID="txt_from"               
          WatermarkText="MM/DD/YYYY">
        </cc1:TextBoxWatermarkExtender>
        <cc1:CalendarExtender ID="CalendarExtender1" runat="server"        
          Enabled="true" TargetControlID="txt_from">
        </cc1:CalendarExtender>                          
        <asp:RequiredFieldValidator ID="rfv1" runat="server"                       
          ControlToValidate="txt_from" Display="None" ErrorMessage="Select
          From date!!" Font-Size="Small" ValidationGroup="totalorders">
        </asp:RequiredFieldValidator>
        <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1"       
          runat="server" TargetControlID="rfv1">    
        </cc1:ValidatorCalloutExtender>
  </td>
  <td>
        <asp:Label ID="Label2" runat="server" Text="To Date"
          CssClass="bold"></asp:Label>
  </td>
  <td>
        <asp:TextBox ID="txt_to" runat="server"></asp:TextBox>
        <cc1:TextBoxWatermarkExtender ID="txt_to_TextBoxWatermarkExtender"
         runat="server" Enabled="True" TargetControlID="txt_to"
         WatermarkText="MM/DD/YYYY">
        </cc1:TextBoxWatermarkExtender>
        <cc1:CalendarExtender ID="CalendarExtender2" runat="server"   
          nabled="true" TargetControlID="txt_to">
        </cc1:CalendarExtender>
        <asp:CompareValidator ID="cvd11" runat="server"
          ControlToCompare="txt_from"
          ControlToValidate="txt_to" 
          ErrorMessage="Greater than to From Date" Font-Size="Small"
          Operator="GreaterThanEqual" SetFocusOnError="True" Type="Date"
          Display="None"  ValidationGroup="totalorders">
        </asp:CompareValidator>
      
       <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender4"       
         runat="server" TargetControlID="cvd11" >                 
       </cc1:ValidatorCalloutExtender>
   </td>
 </tr>
 <tr>
   <td align="center" colspan="4">
       <asp:CompareValidator ID="Compval3" runat="server"                   
       ControlToValidate="txt_from" Display="None"
       ErrorMessage="Check To Date !!.." Operator="DataTypeCheck" Type="Date"
       ValidationGroup="totalorders"></asp:CompareValidator>
     <asp:CompareValidator ID="Compval2" runat="server"
       ControlToValidate="txt_to" Display="None"
       ErrorMessage="Check To Date !!.." Operator="DataTypeCheck" Type="Date"
       ValidationGroup="totalorders"></asp:CompareValidator>
     <cc1:ValidatorCalloutExtender ID="Compval2_ValidatorCalloutExtender"
       runat="server" Enabled="True" TargetControlID="Compval2">
     </cc1:ValidatorCalloutExtender>
     <cc1:ValidatorCalloutExtender ID="Compval3_ValidatorCalloutExtender"
       runat="server" Enabled="True" TargetControlID="Compval3">
     </cc1:ValidatorCalloutExtender>
     <asp:Button ID="btn_goTransation" runat="server" Text="Go"
      onclick="btn_goTransation_Click" ValidationGroup="totalorders" />
     <asp:RequiredFieldValidator ID="rfv2" runat="server"               
      ControlToValidate="txt_to" Display="None" ErrorMessage="Select To
      date!!" Font-Size="Small" ValidationGroup="totalorders">
     </asp:RequiredFieldValidator>
     <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender3"
      runat="server" Enabled="True" TargetControlID="rfv2">
     </cc1:ValidatorCalloutExtender>   
     <asp:RangeValidator ID="Rv_NotGToday" runat="server"
      ControlToValidate="txt_to" Display="None"
      ErrorMessage="To Date is not Greater than Today Date ..!" Type="Date"
      ValidationGroup="totalorders"></asp:RangeValidator>
     <cc1:ValidatorCalloutExtender ID="Rv_NotGToday_ValidatorCalloutExtender"
     runat="server" Enabled="True" TargetControlID="Rv_NotGToday">
     </cc1:ValidatorCalloutExtender>
</td>
</tr>
 </table>


1 comment: