Click here to Skip to main content
15,909,939 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi i had a textbox which has two digits...now after two digits a dot and four zeroes should append.......
also if the tetxbox already contains dot i should not append dot only four zeroes need to append..
please suggets
Posted
Comments
BK 4 code 31-Dec-13 0:33am    
just let me know on which event you want to change your text box value ,ex. textchanged event, lost focus event, got focus event?
Sergey Alexandrovich Kryukov 31-Dec-13 0:39am    
Two digits of what? A dot of what? why?... what's the problem?
—SA
spanner21 31-Dec-13 0:43am    
hi if i have tetxbox text has xyz automatically xyz.0000 should be appear...but if i have xyz.0 then also it should be xyz.0000...pls suggets
Sergey Alexandrovich Kryukov 31-Dec-13 0:47am    
Okay, if you don't want to clarify, don't... :-)
—SA
spanner21 31-Dec-13 0:50am    
hi SA if i eneter any value in tetxbox to that textbox a dot and four zeroes should append automatically

1 solution

C#
formatmask(string str)
{
st=st.Trim();
if(st.Length>0 && st!=null)
{
if(!st.Contains('.'))
{
st=st+ '.';
st=st.PadRight(st.length+4 .'0');
}
else
{
string[] ds=st.split('.');
string aftervalue=ds[1].ToString();
if(aftervalue.Length<=4)
{
aftervalue=aftervalue.PadRight(4,'0');
}
st=ds[0].ToString()+"."+aftervalue;
}
}
rturn st;
}
}



protected void txt_TextChanged(onject sender,Eventraggs e))
{

txtformat.text=formatmask(txtformat.Text);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900