davearia Posted July 21, 2005 Posted July 21, 2005 Hi All, I have 2 more easier questions I would like to ask: 1. How in code do you set a textbox on an ASP.NET page to get focus? (I have looked on the web and such also used the intellisense but no luck) 2. How do I format a string to currency? (So that if there is any decimal values they are always 2 decimal places or if there is no decimal values show no decimal places) I have had two attempts: lblQuote.Text = "Charge for walls = £" + String.Format("{0:C}", Convert.ToString(wallCost)) lblQuote.Text = "Charge for walls = £" + String.Format("{0:F2}", Convert.ToString(wallCost)) These work in as much as they only allow 2 decimal places maximum, however they would display £10.10 as £10.1. How can I avoid this? Many thanks, Dave. :D Quote
davearia Posted July 21, 2005 Author Posted July 21, 2005 Looking at an older project I may have set focus like this: strScript = "<script language=javascript> document.all('txtJumpTo').focus() </script>" RegisterStartupScript("focus", strScript) Quote
Hyuga Posted July 22, 2005 Posted July 22, 2005 This worked for me: Dim p as Double = "1234,10" output.Text = p.ToString("c") where output is a label, the important is the "c" parameter used in the ToString function, it formatted the number into currency, and respected the ending zero. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.