Copied to clipboard

Flag this post as spam?

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


  • Tim 168 posts 372 karma points
    Oct 29, 2009 @ 16:58
    Tim
    0

    Getting a media item in code behind

    What's the best way to output a media item's URL from the code behind in 4.0.2.1? At the moment we have a user control with a Media Picker and then code needs to use the URL.

    umbraco.

    library.GetMedia gives us the node but it seems a bit silly to go back to XSLT to traverse the nodes...

    Thanks.

    Tim

  • Comment author was deleted

    Oct 29, 2009 @ 17:26

    umbraco.cms.businesslogic.media.Media mymedia = new umbraco.cms.businesslogic.media.Media(theid);
    mymedia.getProperty("umbracoFile").Value.ToString()

  • Tim 168 posts 372 karma points
    Oct 29, 2009 @ 17:31
    Tim
    0

    Ahh I had a feeling there would be. Thanks Tim.

     

    Tim

  • Dilipkumar 1 post 21 karma points
    Jan 22, 2013 @ 08:40
    Dilipkumar
    0

    Hello..I am facing the same problem...

    umbraco.cms.businesslogic.media.Media mymedia = new umbraco.cms.businesslogic.media.Media(theid);

    mymedia.getProperty("umbracoFile").Value.ToString()

    I am using the above two lines to get the URL of the media element but getting the exception as
    "The type initializer for 'umbraco.cms.businesslogic.CMSNode' threw an exception."...any help at the earliest please

     


     

Please Sign in or register to post replies

Write your reply to:

Draft