Copied to clipboard

Flag this post as spam?

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


  • Ilias 11 posts 81 karma points
    Feb 26, 2018 @ 12:39
    Ilias
    0

    Change the content of a data type dynamically

    Inside my Razor file I am using:

    <div>
        @Umbraco.Field("myText")
    </div>
    

    as to get and display the content of myText property. The actual content of myText which is a Textstring, is:

    Hello <a href="/main/somefile"> man </a>
    

    I want , somehow, to change on the fly, the content of href by adding a string parameter when calling myText from Razor. Is that possible and how?

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Feb 26, 2018 @ 12:55
    Michaël Vanbrabandt
    0

    Hi Illias,

    can you be more specific of what you are trying to do? Because its not totally clear about what you are asking.

    Is the url a link to a media file in Umbraco? If so then you can use media pickers to pick a file from the media section and render the url into the razor code.

    /Michaël

  • Ilias 11 posts 81 karma points
    Feb 26, 2018 @ 13:13
    Ilias
    0

    I have a landing page with different URL source codes. Depending on the source code, the above razor file has to choose a different path as the destination of "man" hyperlink. So, my point is how to change dynamically the path of href. Does that make sense or you need some more clarification? Thank you

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Feb 26, 2018 @ 13:17
    Michaël Vanbrabandt
    0

    Illias,

    by source code you mean template I guess? Do you have some printscreens about your setup?

    /Michaël

  • Ilias 11 posts 81 karma points
    Feb 26, 2018 @ 14:03
    Ilias
    0

    Okay, do not get confused with source code. I just want to change the href path by code. In that case, the content in Umbraco should include a variable, something like

    Hello <a href="myPath"> man </a>
    

    and the value of myPath should be defined on code. As simple as that.

Please Sign in or register to post replies

Write your reply to:

Draft