Wednesday, November 2, 2011

AJAX Control MaskedEditExtender


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 :-
  1. MaskType
  2.  - Type of validation to perform:
    None - No validation
    Number - Number validation
    Date - Date validation
    Time - Time validation
    DateTime - Date and time validation
  3. 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 "/"
  4. AcceptAMPM - True to display an AM/PM symbol
  5. 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
  6. 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
  7. AutoCompleteValue - Default character to use when AutoComplete is enabled
  8. Century - Default century used when a date mask only has two digits for the year
  9. ClearMaskOnLostFocus - True to remove the mask when the TextBox loses focus
  10. ClearTextOnInvalid - True to clear the TextBox when invalid text is entered
  11. ClipboardEnabled- True to allow copy/paste with the clipboard
  12. ClipboardText - Prompt text to use when a clipboard paste is performed
  13. 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
  14. ErrorTooltipCssClass - CSS class for the tooltip message
  15. ErrorTooltipEnabled - True to show a tooltip message when the mouse hovers over an invalid TextBox
  16. Filtered - Valid characters for mask type "C" (case-sensitive)
  17. InputDirection - Text input direction
    LeftToRight - Left to Right
    RightToLeft - Right to left
  18. MessageValidatorTip - Message displayed when editing in TextBox
  19. PromptChararacter - Prompt character for unspecified mask characters
  20. UserDateFormat - Custom date format
  21. UserTimeFormat - Custom time format
  22. OnFocusCssClass - CSS class used when the TextBox receives focus
  23. OnFocusCssNegative - CSS class used when the TextBox gets focus with a negative value
  24. OnBlurCssNegative - CSS class used when the TextBox loses focus with a negative value
  25. OnInvalidCssClass - CSS class used when the text is not valid.
  26. CultureName - Name of culture to use (overrides the default page culture)
  27. CultureAMPMPlaceholder - Culture override
  28. CultureCurrencySymbolPlaceholder - Culture override
  29. CultureDateFormat - Culture override
  30. CultureDatePlaceholder - Culture override
  31. CultureDecimalPlaceholder - Culture override
  32. CultureThousandsPlaceholder - Culture override
  33. CultureTimePlaceholder - Culture override
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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" />

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!!!!!! :)


Tuesday, November 1, 2011

the page has one or more that do not correspond with controls in masterpage

Error:- 


the page has one or more <asp:content> that do not correspond with <asp:ContentPlaceHolder> controls in masterpage



sometimes working on the large project suddenly you will get this error and you will struct there...

B'coz this is a unusual error and Error itself is not explaining the problem. and other thing  you will not get this error while debugging the project or running the project.  your project will run smoothly without any problem.
you will get this error when you will try to open your page in design view from microsoft visual studio.

you will unable to view the design layout of the pages of your projects. its quite uncomfortable to work without checking design layout. so finally you will search and try to solve this problem. 

for coders, it's very difficult to solve the error which is very tough to understand after reading it many times.

for solution you will definitely check the master page and also contentplaceholder. you will also check all the server tag and name of contentplaceholder of the master page and child page. you will fill very complex as all the contentplaceholder have the proper names.

Soooooooo.. here the solutions is.


1) Open your master page file.
2) check for the all the tags. start with <link> <title> <head> <style> <script>

you will surely forget to close one of this tag.

keep in mind that <title> tag should be closed with </title> not with <title / >

still if you are getting the same error then close all the tag same as <title></title>

now check the design layout of the pages. it will load the layout properly from now.


Try this!!!!!!!!!! :)