Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bora B 32 posts 124 karma points
    Mar 07, 2016 @ 14:32
    Bora B
    0

    toUpper() in a different culture

    Hi,

    I have the following code. The culture is set to en-US because the site is in English but I have peoples name to be in uppercase which are Turkish.

    How do I uppercase the item.memberName in another culture like tr-TR

    Thanks,

    @{ var selection = CurrentPage.Children("TeamMember").Where("Visible"); }
    
    @if (selection.Any())
    {
            @foreach (var item in selection)
            {
                <h3>@item.memberName</h3>
    }
    }
    
  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Mar 07, 2016 @ 14:39
    Dennis Adolfi
    0

    Could this maybe work?

    @using System.Globalization
    
    @item.memberName.ToUpper(new CultureInfo("tr-TR", false));
    
  • Bora B 32 posts 124 karma points
    Mar 07, 2016 @ 14:53
    Bora B
    0

    Thanks Dennis but I already tried that. I get the following error

    TeamCarousel.cshtml(16): error CS0246: The type or namespace name 'CultureInfo' could not be found (are you missing a using directive or an assembly reference?)

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Mar 07, 2016 @ 14:55
    Dennis Adolfi
    100

    Did you use the @using statement that i wrote above?

    @using System.Globalization
    

    or use without using namespace directive:

    @item.memberName.ToUpper(new System.Globalization.CultureInfo("tr-TR", false));
    
  • Bora B 32 posts 124 karma points
    Mar 07, 2016 @ 15:38
    Bora B
    0

    Thanks again you are right I missed that :)

Please Sign in or register to post replies

Write your reply to:

Draft