Try our conversational search powered by Generative AI!

Get EpiServer.Url data

Vote:
 

I have created a block that contains a property marked as Url so that a user can select either a page, external link ect. However my block contrain a hyperlink wrapping an image tag so unless i'm mistaken I can't use the Html helpers to generate the link. I want code to work out what the correct link would be e.g.

  • If it's an external link just give me the string
  • If it's a reference give me the friendly URL
  • If it's a mailto give me the string

I used to be able to do this in 6 but am having trouble finding the necessary code to just get me the correct Href attribute for each of the different types.

Thanks,

Scott 

#76344
Oct 22, 2013 14:50
Vote:
 

Have you tried just using the Html.PropertyFor() extension method to generate the markup code? It should be very similar to the <EPiServer:Property web control and render different markup based on the type and content.

Frederik 

#76353
Oct 22, 2013 21:08
Vote:
 

I'm not having problem with understanding the MVC extensions I've been using Html.PropertyFor() extensivly when I can I just don't see how in this scenario. Effectivly I have a block which has 2 properties, one that's a Url but set to be an image using the ui hint and one that's a standard Url. The user need to be able to set the image and then set the Url and then in the block razor I want generated

<a href="{URLLOCATION}">

   <img src="{IMAGELOCATION" alt="{IMAGEDESCRIPTION}" />

</a>

I've already got all of the code for pulling the description from the asset library out but I couldn't see a way on PropertyFor to set a template, all I need is the href location that is autogenerated by PropertyFor.

 

#76419
Oct 24, 2013 10:24
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.