0

I have text box that user write the price inside it , I need to know how to add the format to be look like 1236,650 for example The problem I faced that when the user write the price like 6.500 and then save it , it's become like 6.5

this is my text box

  <asp:TextBox ID="TxtPrice" runat="server" 
                    style="text-align:right; margin-left: 0px;" Height="19px" Width="109px" ></asp:TextBox>
rere
  • 41
  • 1
  • 12
  • Are you saying it changes on postback or are you reloading the page later and the format is incorrect? – Straw Jack Feb 15 '15 at 15:41
  • http://stackoverflow.com/questions/202067/force-asp-net-textbox-to-display-currency-with-sign – Steve Feb 15 '15 at 15:42

1 Answers1

0

I would get the substring after the decimal point: string substring = [Example TextBox].Text.SubString([Example TextBox].Text.LastIndexOf('.')); Before setting up a loop that adds 0s until the length is adequate

while (substring.Length < 3) { substring += "0"; } Before making it the string of the TextBox again. I'm not really familiar with ASP so this last part I'm unaware of. But you tagged C# so I assume you can follow these other steps.

Sophie Coyne
  • 1,018
  • 7
  • 16