Tuesday, 22 October 2013

How to use Ajax FilteredTextBoxExtender for validating in ASP.NET

Hi friends, in this article I will explain about How to use Ajax FilteredTextBoxExtender for validating in ASP.NET.
I already explained in the previous articles about How to turn a Textbox into a rich HTML editor using AjaxControlTookitHow to Build Modal Popup using ASP.Net AJAX ModalPopupExtender Control in ASP.NET and ASP.NET AjaxFileUpload Control With Progress Bar using C# or VB.NET || Drag and Drop the multiple files using AjaxFileUpload Control With Progress Bar in ASP.NET using C# or VB.NET

In .aspx page we have to add below code to access AjaxControlToolkit
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

In ASP.NET:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>How to use Ajax FilteredTextBoxExtender for validating in ASP.NET</title>
    <style type ="text/css" >
    table ,tr,td,th
    {
        border: 1px solid gray;
    }
    h4
    {
        font-family :Verdana;
        font-style :normal ;
        color:Green ;
    }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
      <div>
      <h4>
      How to use Ajax FilteredTextBoxExtender for validating in ASP.NET
      </h4>
    <table >
    <tr>
    <td>  Numbers and Digits :</td>
    <td>
     <asp:TextBox ID="txtPhoneNo" TabIndex="1"  runat="server"></asp:TextBox>
     <ajax:FilteredTextBoxExtender ID="FTBE_nos"  runat="server"  FilterType="Numbers"  TargetControlID="txtPhoneNo" /><br />
     </td>
     </tr>
     <tr>
     <td>Alphabets (Uppercase and Lowercase)</td>
     <td>
      <asp:TextBox ID="txtUpLw" TabIndex="2"  runat="server"></asp:TextBox>
      <ajax:FilteredTextBoxExtender ID="FTBE_U_l"  runat="server"  FilterType="LowercaseLetters, UppercaseLetters"  TargetControlID="txtUpLw" /><br />
     </td>
     </tr>
     <tr>
     <td>Alphabets (Uppercase only)
     </td>
     <td>
      <asp:TextBox ID="txtUp" TabIndex="3"  runat="server"></asp:TextBox>
      <ajax:FilteredTextBoxExtender ID="FTBE_abc"  runat="server"  FilterType="UppercaseLetters"  TargetControlID="txtUp" /><br />
      </td></tr>
      <tr><td>  Alphabets (Lowercase only)</td>
      <td>
       <asp:TextBox ID="txtLwr" TabIndex="4"  runat="server"></asp:TextBox>
      <ajax:FilteredTextBoxExtender ID="FTBE_L"  runat="server"  FilterType="LowercaseLetters"  TargetControlID="txtLwr" /><br />
      </td>
      </tr>
      <tr>
      <td>Alphabets and Numbers (Alphanumeric)
      </td>
      <td>
       <asp:TextBox ID="txt_abc_nos" TabIndex="5"  runat="server"></asp:TextBox>
      <ajax:FilteredTextBoxExtender ID="FTBE_abc_nos"  runat="server"  FilterType="LowercaseLetters, UppercaseLetters,Numbers"  TargetControlID="txt_abc_nos" /><br />
      </td>
      </tr>
      <tr>
      <td> Email Address (Lower case alphabets, numbers, @ and dot)
      </td>
      <td>
       <asp:TextBox ID="txtEmail" TabIndex="6"  runat="server"></asp:TextBox>
      <ajax:FilteredTextBoxExtender ID="FTBE_Email"  runat="server"  FilterType="LowercaseLetters, Numbers,Custom"  TargetControlID="txtEmail" ValidChars=".@"/><br />
      </td></tr>
      <tr>
      <td> Decimal Number(Digits and dot)
      </td>
      <td>
       <asp:TextBox ID="txt_num" TabIndex="7"  runat="server"></asp:TextBox>
      <ajax:FilteredTextBoxExtender ID="FTBE_dec_dot"  runat="server"  FilterType="Numbers, Custom"  TargetControlID="txt_num" ValidChars ="." /><br />
     </td></tr>
     <tr>
     <td>Money or Currency (Digits, comma and dot)</td>
     <td>
      <asp:TextBox ID="txt_money" TabIndex="8"  runat="server"></asp:TextBox>
      <ajax:FilteredTextBoxExtender ID="FTBE_money"  runat="server"  FilterType="Numbers, Custom"  TargetControlID="txt_money"  ValidChars =",."/><br />
       </td></tr>
     </table>
     <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
 
    </form>
</body>
</html>


The output of the above code as shown in the below figure.

No comments:

Post a Comment

© 2012-2014 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.