1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to capital a word by asp

Discussion in 'C#' started by wacamoi, Apr 23, 2009.

  1. #1
    I want to have the first letter become a capital letter

    ex:
    message ---> Message

    please show a easy way


    Thanks
     
    wacamoi, Apr 23, 2009 IP
  2. tihomir_wwf

    tihomir_wwf Active Member

    Messages:
    363
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    73
    #2
    Hi,

    you can try this:

    using System.Globalization;

    ...

    string strTest = "change the first letter of each word of this text to uppercase.";
    TextInfo strTI = new CultureInfo("en-US", false).TextInfo;
    strTest = strTI.ToTitleCase(strTest);
     
    tihomir_wwf, Apr 24, 2009 IP
    JJnacy likes this.
  3. web-bod

    web-bod Guest

    Messages:
    17
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    bit of a cheat but you could do it in your style sheet with "text-transform: capitalize;"
     
    web-bod, Apr 24, 2009 IP
    wacamoi likes this.
  4. emlak

    emlak Peon

    Messages:
    50
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    
    
    a="message"
    a=trim(a)  ' replace space 
    
    first_letter=left(a,1)
    other_letters=right(a,len(a)-1)
    first_letter=[b]ucase[/b](first_letter)
    result=first_letter&other_letters
    response.write result  ' Message
    
    
    
    
    
    
    Code (markup):
    I am using this technique at my emlak site here is link http://www.emlakset.com/main.asp?cat=1
     
    emlak, Apr 25, 2009 IP
    wacamoi likes this.
  5. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    
    <%
            Dim a
            a = "message"
            a = Ucase(Mid(a, 1, 1)) & Mid(a, 2)
            Response.Write a
    %>
    
    Code (markup):
    or if you want a function:

    
    <%
    Function capitalize(strText)
    	capitalize = Ucase(Mid(strText, 1, 1)) & Mid(strText, 2)
    End Function
    %>
    
    Code (markup):
     
    camjohnson95, Apr 28, 2009 IP
    Link.ezer.com likes this.
  6. wacamoi

    wacamoi Peon

    Messages:
    810
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for all helps.

    now works very well
     
    wacamoi, Apr 28, 2009 IP