문제

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