asp.netajaxcontroltoolkitmaskededitextendermaskedinput

AjaxControlToolkit MaskedEditExtender - custom mask appearance


I'm using a MaskedEditExtender to show users what format they should use to enter a date into a textbox. How do I change the mask to be dd/MM/yyyy instead of __/__/____?


Solution

  • I looked over the source code for the MaskedEditExtender, and it doesn't look it it supports what you want out of the box. You can replace the '_' with some other character with the PromptCharacter property, but to do what you want, you'd need to edit MaskedEditBehavior.js in the control's source code. Search for _PromptChar to find the relevant sections.

    For a quick workaround, you could create an image of "dd mm yy" and use CSS to set it as the textbox's background image. Then the existing mask from the MaskedEditExtender will appear ontop of the image. Maybe use PromptCharacter=' ' (space) to make it look a little cleaner.

    .dateTextBox{
    background-image:url('images/my_hacky_dateformat_image.gif');
    background-repeat:no-repeat;
    padding-left:5px;
    }