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

Ajax Toolkit FilteredTextBoxExtender Control in ASP.Net


AJAX AJAX 
Ratings:
1 Comment(s)
 15337  View(s)
Rate this:

Ajax Toolkit FilteredTextBoxExtender Control in ASP.Net

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

AjaxControl 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.

AjaxControl Toolkit FilteredTextBoxExtender Control in ASP.Net


FilteredTextBoxExtender Allow the "Enter" key

By Somak Sen on   3 years ago
How we can allow the "Enter" key ?
When Asp.Net TextBox property "TextMode" is "MultiLine" want to allow "Enter" key option by using FilteredTextBoxExtender's FilterType.

Don't want to miss updates? Please click the below button!

Follow MindStick