Sunday, 23 February 2014

Ajax FilteredTextBox with Example in ASP.NET


In this article I will explain what is Ajax FilteredTextBox with Example in ASP.NET.

FilteredTextBox is an extender which prevents a user from entering invalid characters into a text box. Note that since this effect can be avoided by deactivating JavaScript, you should use this extender as a convenience for your users, but you must never expect that the data being sent to the server consists of "valid" chars only.

Example 1:

<Ajax:FilteredTextBoxExtender ID="fteSoldDate" runat="server" TargetControlID="txtSoldDate" FilterType="Custom, Numbers" ValidChars="/+-" />

Example 2:

<Ajax:FilteredTextBoxExtender ID="fteInvoiceNo" runat="server" TargetControlID="txtInvoiceNo" FilterType="Custom, Numbers, UppercaseLetters, LowercaseLetters" ValidChars="" /></td>



Properties:
  1. TargetControlID - The ID of the text box for this extender to operate on
  2. FilterType - A the type of filter to apply, as a comma-separated combination of Numbers, LowercaseLetters, UppercaseLetters, and Custom. If Custom is specified, the ValidChars field will be used in addition to other settings such as Numbers.
  3. FilterMode - A the filter mode to apply, either ValidChars (default) or InvalidChars. If set to InvalidChars, FilterType must be set to Custom; if set to ValidChars, FilterType must contain Custom.
  4. ValidChars - A string consisting of all characters considered valid for the text field, if "Custom" is specified as the filter type. Otherwise this parameter is ignored.
  5. 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. Otherwise this parameter is ignored.
  6. FilterInterval - An integer containing the interval (in milliseconds) in which the field's contents are filtered, defaults to 250.


No comments:

Post a Comment