问题
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 __/__/____
?
回答1:
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;
}
回答2:
did you try the Watermark Extender? just a thought..
Cheers!
回答3:
Hai Kristian,
Try this PromptCharacter="*"
in your ajaxToolkit:MaskedEditExtender
来源:https://stackoverflow.com/questions/1837200/ajaxcontroltoolkit-maskededitextender-custom-mask-appearance