I try to create a mask for a account number, for example:

That I've a function receive an String (11112222334444444444) and I would like to convert to 1111-2222-33-4444444444

applyFormatcccc function string (string cccc)
{
   1. myNum string = string.Format ("# # # # - # # # # - # # - # # # # # # # # # #", cccc);
   2. MyNum return;
}

but, it's impossible to convert because i put an String (cccc) in the first Line (1). other case was:

double num = 11112222334444444444;
worth num.ToString string = ("# # # # - # # # # - # # - # # # # # # # # # #", num)

it's the result: 11112222334444400000 -> only accept 8 bytes

How is the best form to use Apply this mask without an loops (for, while) .. as far as possible

有帮助吗?

解决方案

Try to use Ajax markededitor extender for this.

eg :

< asp:TextBox ID = "TextBox1" runat = "server" ForeColor = "HotPink" >

< cc1:MaskedEditExtender ID = "MaskedEditExtender1" runat = "server" TargetControlID = "TextBox1" Mask = "9999-9999-99-9999999999" MaskType = "Number" MessageValidatorTip = "true" >

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top