articles

Home / DeveloperSection / Articles / Ajax Toolkit FilteredTextBoxExtender Control in ASP.Net

Ajax Toolkit FilteredTextBoxExtender Control in ASP.Net

Amit Singh24193 07-Dec-2010

FilteredTextBox is an extender which prevents a user from entering invalid characters into a text box.

FilteredTextBox Properties:

·      TargetControlID - The ID of the text box for this extender to operate on

·    FilterType- Is applying type of Filter, as a comma-separated combination of Numbers, LowercaseLetters, UppercaseLetters, and Custom

·         FilterMode - It contain ValidChars or InvalidChars.

·         ValidChars - A string consisting of all characters considered valid for the text field, if "Custom" is specified as the filter type.

·         InvalidChars - A string consisting of all characters considered invalid for the text field, if "Custom" is specified as the filter type and "InvalidChars" as the filter mode.

·         FilterInterval - An integer containing the interval (in milliseconds) in which the field's contents are filtered.

Code:

 <%-- ScriptManager control manages client script for AJAX enabled ASP.NET pages.This enables partial-page rendering and Web-service calls.You have to used this if you want to use ajax control toolkit--%>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<%--Use the FilteredTextBox Extender here which control the textbox1--%>
<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="TextBox1" FilterType="Numbers">
</cc1:FilteredTextBoxExtender>
 
<asp:Label ID="Label1" runat="server" Text="Only Number allowed"></asp:Label>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<%--Use the FilteredTextBox Extender here which control the textbox2--%>
 
<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server"
TargetControlID="TextBox2" FilterType="LowercaseLetters">
</cc1:FilteredTextBoxExtender>
<asp:Label ID="Label2"runat="server" Text="Only valid LowercaseLetters "> </asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

Run the project

Ajax Toolkit FilteredTextBoxExtender Control in ASP.Net

In FilteredTextBoxExtender1 filtertype is specified number(FilterType="Numbers") so first textbox accept only number

In FilteredTextBoxExtender2  filtertype is specified lowercaseletter (FilterType="LowercaseLetters") so second textbox accept only lowercase letter.

Ajax Toolkit FilteredTextBoxExtender Control in ASP.Net


Updated 04-Mar-2020

Leave Comment

Comments

Liked By