Copied to clipboard

Flag this post as spam?

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


  • Hubert Thalmann 57 posts 263 karma points
    Sep 05, 2016 @ 08:52
    Hubert Thalmann
    0

    remove http:// and https://

    Hello our.Umbraco Community

    I have a little Problem with the links on my website. The links are defined with http://www.example.com but i want to give out them like "www.example.com"

    here is my code

                foreach (var item2 in selection2)
                {
            <div class="row">
                <div class="col-sm-1 col-xs-0">
            </div>
            <div class="col-sm-5 col-xs-12">
                <label class="subtitle mitabstand">@item2.LinkName<label>
            </div>
            <div class="col-sm-5 col-xs-12 text">
                <p class="text"><a href="@item2.LinkURL" target="_blank">@item2.LinkURL</a></p>
            </div>
            </div>
                }
                <br />
    
    }
    

    by the first (href) i want to give it out normal: @item2.LinkName is: http://www.example.org

    and by the second after the target="_blank" i want to give it out without http:// and https://

    i think i have to make a new var and then do some string-modeling.

    Can someone help me?

  • Karl Kopp 121 posts 227 karma points
    Sep 05, 2016 @ 09:06
    Karl Kopp
    100

    It's a simple C# string, so you can use the .NET Replace method on it.

    @item2.LinkURL.Replace("http://","").Replace("https://","")
    

    I'm sure there is a regex way to do it too, this is just an example :)

  • Hubert Thalmann 57 posts 263 karma points
    Sep 05, 2016 @ 09:19
    Hubert Thalmann
    0

    thank you so much

  • 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