AJAX FilteredTextbox Control Extender

by top54u.com 29 May, 2008

The FilteredTextbox Extender control enables the Textbox server control of ASP.Net to filter the input given by user that allows only valid input characters into the textbox. You can use the FilteredTextboxExtender for the field of username to validate and filter the invalid characters e.g.: allows the input characters as alphabets + special characters (- or _) + numbers.

 

There is a limitation of using FilteredTextboxExtender that user can disable the javascript feature of web browser. This allows the user to input any invalid characters. So, you cannot rely totally on this extender control. You must also verify the input before saving it into the data store otherwise it could cause exceptions later on.

 

FilteredTextboxExtender Properties

 

TargetControlID: ID of Textbox control to bind the FilteredTextboxExtender with it.

 

FilterType: There are four types of filters Custom, LowercaseLetters, Numbers, UppercaseLetters. You can specify one of these filters or comma-separated combinations.
If FilterType is set as Custom then you must specify the character ValidChars also.

 

FilterMode: There are two types of filter mode ValidChars, InvalidChars.
ValidChars FilterMode works with FilterType having combination of filters and must contain Custom. You must also specify the valid characters in ValidChars property. InvalidChars FilterMode works only with Custom FilterType.

 

ValidChars: List of valid characters. ValidChars property works only if FilterType contains Custom otherwise it is ignored.

 

InvalidChars: List of invalid characters. Invalid property works with Custom FilterType. Also you must select the InvalidChars FilterMode.

 

FilterInterval: Time in milliseconds to filter the invalid characters within the specified time interval. Default value is 250 milliseconds.

 

 

Sample Code for FilteredTextBoxExtender Control

<asp:TextBox ID="TextBox1" runat="server" Width="250px"></asp:TextBox>



<ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
         TargetControlID="TextBox1"
         FilterType="Custom"
         InvalidChars="aeiouAEIOU"
         FilterMode="InvalidChars">
</ajaxToolkit:FilteredTextBoxExtender>

 

Download the free sample code for different types of FilteredTextboxExtender here...

ajax FilteredTextbox extender.zip (1.50 kb)

Spotlight.....

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , ,

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

10/11/2008 3:22:38 AM




related videos.....
recent posts.....
top54u ezines.....