FilteredTextBox 是一个可以用于在客户端避免网页的用户输入无效字符的控件。与 Validator 不同,它所采用的方式是“避免”用户对于无效字符的按键响应,而达到其过滤的效果。
注意:
FilteredTextBox 的过滤功能可以被客户端浏览器关闭 JavaScript 而导致无效,所以该控件不能保证所发回服务器端的数据都是“有效”数据。
FilteredTextBox 属性
<ajaxToolkit:FilteredTextBoxExtender ID="ftbe" runat="server"
TargetControlID="TextBox3"
FilterType="Custom, Numbers"
ValidChars ="+-=/*()." />
- TargetControlID - 需要具有“过滤”功能的 TextBox 控件 ID
- FilterType - 被约束的方式,包括: Numbers , LowercaseLetters , UppercaseLetters , 和 Custom ; 可以采用逗号(,)进行组合。 如果指定了 Custom,那么 ValidChars 属性将被用于指定有效的字符。
- FilterMode - 采用的约束模式,可以是 ValidChars (默认) 或者 InvalidChars 。如果被设置为 InvalidChars,那么 FilterType 必须被设置为Custom;如果被设置为ValidChars, 那么 FilterType 必须包含 Custom。
- ValidChars - 一个用字符串表示的有效字符集合,如果没有在 FilterType 设置了 Custom,那么该设置将会被忽略。
- InvalidChars - 一个用字符串表示的非法字符集合,如果没有在 FilterType 设置了 Custom ,那么该设置将会被忽略。
- FilterInterval - 一个用整数标示的产生“过滤”时间间隔,用毫秒表示,默认为250(毫秒)。