You must Sign In to post a response.
Category: ASP.NET
#767357
Hi,
OnKeyPress event of textbox you can wrote below lines of code
Hope this will helpful to you...
--------------------------------------------------------------------------------
Give respect to your work, Instead of trying to impress your boss.
N@veen
Blog : http://naveens-dotnet.blogspot.in/
OnKeyPress event of textbox you can wrote below lines of code
Protected void txt1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled =!char.IsDigit(e.KeyChar) && e.KeyChar !=(char)8;
txt1.Text=string.Format("{0:n0}", Double.Parse(txt1.Text));
}
Hope this will helpful to you...
--------------------------------------------------------------------------------
Give respect to your work, Instead of trying to impress your boss.
N@veen
Blog : http://naveens-dotnet.blogspot.in/
#767377
Hi
try this code
refer his url
"forums.asp.net/t/1616010.aspx?Implementation+of+thousand+separator+for+a+Textbox"
Name : Dotnet Developer-2015
Email Id : kumaraspcode2009@gmail.com
'Not by might nor by power, but by my Spirit,' says the LORD Almighty.
try this code
<asp:TextBox
ID="budgetText"
runat="server"
Text='<%# string.Format(CultureInfo.InvariantCulture, "{0:#,0.00}", Bind("Budget")) %>'
refer his url
"forums.asp.net/t/1616010.aspx?Implementation+of+thousand+separator+for+a+Textbox"
Name : Dotnet Developer-2015
Email Id : kumaraspcode2009@gmail.com
'Not by might nor by power, but by my Spirit,' says the LORD Almighty.
#767378
when you assign a value to textbox you can use 'string.Format' method, it just Converts the value of objects to strings based on the formats specified and inserts them into another string
above code will works as expected just you need to make sure that input text should be only Integer or Double value
or simply you can use globalization as Indian, see below snippet
Thanks
Koolprasd2003
Editor, DotNetSpider MVM
Microsoft MVP 2014 [ASP.NET/IIS]
textBox1.Text = string.Format("{0:#,##0.00}", double.Parse(textBox1.Text));
above code will works as expected just you need to make sure that input text should be only Integer or Double value
or simply you can use globalization as Indian, see below snippet
textBox1.Text = string.Format(System.Globalization.CultureInfo.GetCultureInfo("id-ID"), "{0:#,##0.00}", double.Parse(textBox1.Text));
Thanks
Koolprasd2003
Editor, DotNetSpider MVM
Microsoft MVP 2014 [ASP.NET/IIS]
Return to Return to Discussion Forum