why AllowPromptAsInput property is not worked when PromptChar = '0' in C#? [closed]

5 days ago 2
ARTICLE AD BOX

I create a MaskedTextBox for BirthDate where Mask = "00/00/0000" and when User try to Enter 0 Like 02/02/2001 the result is 2/2/2 1.
I try to make AllowPromptAsInput = true but nothing happen. Any suggestions Please.

NightQnEarth's user avatar

ilxdev's user avatar

New contributor

ilxdev is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

7

What kind of application is this and what's the actual code? All desktop and web stacks have both date pickers and masked input controls. Why are you using a masked box instead of a date picker to enter dates? My suggestion is to use the correct control for the job -

2026-03-30 10:29:38 +00:00

Commented 21 hours ago

Look at the Windows Forms MaskedEditBox.Text example for code that shows the actual settings and what happens when different strings are entered. In any case, I'd never use a masked input to insert dates. Is 12/31/2001 valid or not? You don't know, you have to guess before parsing. With a date picker on the other hand, the input is already validated and you get back a valid DateTime. The UI itself adapts to different locales and makes it clear what each part is

2026-03-30 10:41:14 +00:00

Commented 21 hours ago

@PanagiotisKanavos Thank you for your answer. I am just practising, which is why I am using a MaskedTextBox

2026-03-30 11:34:42 +00:00

Commented 20 hours ago

That's not a minimal reproducible example. You need to edit your question with the code/XAML involved - making it really clear which UI framework we're using. Someone should be able to read the question (without having to read the comments) and reproduce the problem without having to guess at anything.

2026-03-30 11:54:04 +00:00

Commented 20 hours ago

Read Entire Article