Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2004, 12:27 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default String formatting

Just wondering if there is a way (natively) to format a string in .NET like the InitCap function does in Oracle.

That is, the text "GOOD MORNING" would format to "Good Morning".

Any ideas??

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
 
Old July 7th, 2004, 01:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I don't know if there is, but if there isn't, an alternative that you could do is:

Dim strWords() As String = "GOOD MORNING".Split(" ".ToCharArray())
Dim strText As String = ""

For intI As Integer = 0 To strWords.Count
  Dim strWord As String = strWords(intI)
  strText &= strWord.Substring(0, 1).ToUpper() & _
   strWord.Substring(1).ToLower()
Next

Response.Write(strText)

Something like that you could do. Basically break the string apart by the space; cast the first letter to upper case with ToUpper(), and cast the rest to lower case with ToLower().

Brian
 
Old July 8th, 2004, 12:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

If
  • its only for display
  • Clint-Side can help u
  • u dont wanna use Server-Side programming
CSS could help for for that too!

Always:),
Hovik Melkomian.
 
Old July 8th, 2004, 05:21 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

 text-transform:capitalize ;

Ahmed Ali
Software Developer
 
Old July 9th, 2004, 02:47 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried the CSS solution, and it didn't work for me, so I dug a little deeper and found the StrConv function:

Code:
Dim result As String
result = StrConv(result, VbStrConv.ProperCase)
Obviously this is VB-centric, but I would think there is an equivalent in C#

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting string with comma arnabghosh SQL Server 2005 1 October 16th, 2007 01:38 AM
String Formatting sumith ASP.NET 2.0 Basics 1 October 3rd, 2007 07:35 AM
String formatting MargateFan XSLT 4 May 5th, 2006 04:54 AM
how to replace a string with another string/number crmpicco Javascript How-To 4 March 14th, 2005 12:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.