Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    Jun 19, 2013 @ 12:06
    René Andersen
    0

    Remove spaces and change to lowercase

    Hello

    Can anybody tell me how to change a text like "News April 2012" to "news_april_2012" or "newsapril2012". I need it because my gallery categories has to be without spaces and lowercase.
    At the moment the problem is solved by using a textstring for the name "News April 2012" and another textstring for the category where the user has to type in "newsapril2012" and I want this to be done only using the name text string "News April 2012" and then the Razor convert the text.
    In the code below I need the "@page.category" to be converted.

    <div class="portfolio-title">
    <h2>@Model.headline</h2>
    <ul id="filter">
    <li><a href="#" class="active" data-filter="*">All</a></li>
    @foreach (var page in @Model.Children)
    {

    <li><a href="#" data-filter="[email protected]">@page.galleryName</a></li>
    }
    </ul>
    </div>

    Thank you!

    //René

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 19, 2013 @ 12:10
    Fuji Kusaka
    102

    Hi Rene,

    Try something like 

    @page.galleryName.ToLower().Replace(" ", "")
  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jun 19, 2013 @ 12:10
    Tim Geyssens
    2

    try @page.category.ToLower().Replace(' ', '_') @page.category.ToLower().Replace(' ', '')

  • René Andersen 238 posts 684 karma points
    Jun 19, 2013 @ 12:19
    René Andersen
    0

    Hi Fuji / Tim

    Thanks to both of you, it worked like a charm. :-)

    // René

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies