Data annotations - DisplayFormat - formatting string of numbers

asp.net-mvc asp.net-mvc-3 c# data-annotations entity-framework

Question

I have the following string: "10222002750400447092095835"

I want it to be displayed like this: 10 2220 0275 0400 4470 9209 5835

I tried doing the following, with no result at all:

[DisplayFormat(DataFormatString = "{0:00 0000 0000 0000 0000 0000 0000}", ApplyFormatInEditMode = true)]

or

[DisplayFormat(DataFormatString = "{0:## #### #### #### #### #### ####}", ApplyFormatInEditMode = true)]

What am I doing wrong?

1
2
2/7/2013 7:39:40 PM

Accepted Answer

I believe what you are looking for is String masking. See below.

Stackoverflow - How to mask a string Stackoverflow - Apply mask to string

1
5/23/2017 10:27:58 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow