AJAX's MaskedEditExtender
Examples of basic properties which we can be used frequently
Enter a Number (format: 9,999,999.99): Tip: Type '.' to switch
<ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1"
Mask="9,999,999.99" MessageValidatorTip="false" MaskType="Number" InputDirection="RightToLeft" />
Enter Time (format: 99:99:99):
Tip: Type 'A' or 'P' to switch AM/PM
<ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1"
Mask="99:99:99" MessageValidatorTip="false" MaskType="Time" InputDirection="RightToLeft"
AcceptAMPM="true" />
Enter Date (format: 99/99/9999):
Tip: The date format is mm/dd/yyyy for this example and a Calendar is also available for date selection
<ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1"
Mask="99/99/99" MessageValidatorTip="false" MaskType="Date" InputDirection="RightToLeft" />
Enter Date and Time (format: 99/99/9999 99:99:99)
<ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1"
Mask="99/99/9999 99:99:99" MessageValidatorTip="false" MaskType="DateTime" InputDirection="RightToLeft" />
=====================================================
Other Properies of MaskedEditExtender :-
- MaskType - Type of validation to perform:
- Mask Characters and Delimiters
9 - Only a numeric character
L - Only a letter
$ - Only a letter or a space
C - Only a custom character (case sensitive)
A - Only a letter or a custom character
N - Only a numeric or custom character
? - Any character
/ - Date separator
: - Time separator
. - Decimal separator
, - Thousand separator
\ - Escape character
{ - Initial delimiter for repetition of masks
} - Final delimiter for repetition of masks
Examples:
9999999 - Seven numeric characters
99\/99 - Four numeric characters separated in the middle by a "/" - AcceptAMPM - True to display an AM/PM symbol
- AcceptNegative - True if the negative sign (-) is allowed
None - Do not show the negative sign
Left - Show the negative sign on the left of the mask
Right - Show the negative sign on the right of the mask - AutoComplete - True to automatically fill in empty mask characters not specified by the user
MaskType=Number - Empty mask characters will be filled with zeros
MaskType=Time - Empty mask characters will be filled with the current time
MaskType=Date - Empty mask characters will be filled with the current date
MaskType=DateTime - Empty mask characters will be filled with the current date/time - AutoCompleteValue - Default character to use when AutoComplete is enabled
- Century - Default century used when a date mask only has two digits for the year
- ClearMaskOnLostFocus - True to remove the mask when the TextBox loses focus
- ClearTextOnInvalid - True to clear the TextBox when invalid text is entered
- ClipboardEnabled- True to allow copy/paste with the clipboard
- ClipboardText - Prompt text to use when a clipboard paste is performed
- DisplayMoney - Specifies how the currency symbol is displayed
None - Do not show the currency symbol
Left - Show the currency symbol on the left of the mask
Right - Show the currency symbol on the right of the mask - ErrorTooltipCssClass - CSS class for the tooltip message
- ErrorTooltipEnabled - True to show a tooltip message when the mouse hovers over an invalid TextBox
- Filtered - Valid characters for mask type "C" (case-sensitive)
- InputDirection - Text input direction
LeftToRight - Left to Right
RightToLeft - Right to left - MessageValidatorTip - Message displayed when editing in TextBox
- PromptChararacter - Prompt character for unspecified mask characters
- UserDateFormat - Custom date format
- UserTimeFormat - Custom time format
- OnFocusCssClass - CSS class used when the TextBox receives focus
- OnFocusCssNegative - CSS class used when the TextBox gets focus with a negative value
- OnBlurCssNegative - CSS class used when the TextBox loses focus with a negative value
- OnInvalidCssClass - CSS class used when the text is not valid.
- CultureName - Name of culture to use (overrides the default page culture)
- CultureAMPMPlaceholder - Culture override
- CultureCurrencySymbolPlaceholder - Culture override
- CultureDateFormat - Culture override
- CultureDatePlaceholder - Culture override
- CultureDecimalPlaceholder - Culture override
- CultureThousandsPlaceholder - Culture override
- CultureTimePlaceholder - Culture override
None - No validation
Number - Number validation
Date - Date validation
Time - Time validation
DateTime - Date and time validation
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Now the Main Problem which we usually face with MaskedEditExtender
If you are using MaskedEditExtender with MaskType="Time"
now as we have previously seen that with time type
MaskType=Time => Empty mask characters will be filled with the current time
but we require zero(0) in Empty mask characters instead of current time. as normal user will not understand that it will be filled with current time if they are using this control first time then.
For that I have solution
you can use AutoComplete and AutoCompleteValue properties for this purpose.
SET
AutoComplete="true";
AutoCompleteValue ="00:00";
<ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1" Mask="99:99:99" MessageValidatorTip="false" MaskType="Time" InputDirection="RightToLeft"
AcceptAMPM="false" AutoComplete="true" AutoCompleteValue="00:00" />
AcceptAMPM="false" AutoComplete="true" AutoCompleteValue="00:00" />
it will fill Empty mask characters will be filled with the 0.
you can use this stretergy with any MaskType.
This will really help you!!!!!! :)
No comments:
Post a Comment