Copied to clipboard

Flag this post as spam?

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


  • Bob McLane 19 posts 39 karma points
    Aug 08, 2011 @ 19:48
    Bob McLane
    0

    library.getmedia problem in .NET user control

    I have two issues with a .NET User control I'm building.

    1. I attempt to pass in an ID as a parameter from a Media Picker and that works but when I try to get the path using
    Dim sImgURL As String = library.GetMedia(Me.m_iImageNodeID, 0).ToString()

    all I get back is MS.Internal.Xml.XPath.XPathSelectionIterator

    Any idea what I'm doing wrong?

     

    2. When I try to debug this from Visual studio by hard coding the parameters it seems as if the call to the umbraco dll doesn't work correctly. For example the following statement works correctly and returns the path that I want when I compile and use my control as an umbraco macro but returns '#' when I try to test in visual studio. Do I need to login somehow or something before calling the method?

    Private m_iNavigateNodeID As Integer = 1158 
    Dim sNavURL As String = library.NiceUrl(Me.m_iNavigateNodeID).ToString()
    thanks for the help!
  • Nigel Wilson 945 posts 2077 karma points
    Aug 08, 2011 @ 19:53
    Nigel Wilson
    0

    In option 1 are you ensuring the Me.m_iImageNodeID is an integer ?

    Maybe wrap a Convert.ToInt32 (or the equivalent in VB) around the variable.

    Cheers

    Nigel

  • Bob McLane 19 posts 39 karma points
    Aug 08, 2011 @ 19:57
    Bob McLane
    0

    Yes the Public Property is Integer. I also attempted to hard code the value with the ID and got back the same result.

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 08, 2011 @ 19:57
    Tom Fulton
    0

    Hi,

    #1 - GetMedia is supposed to return an XPathNodeIterator - it returns the Media's attributes/properties in XML format - you can then parse this for umbracoFile or whatever you need.

    Alternatively you can use the media API (umbraco.cms.businesslogic.media) - in C# it's something like this, not sure about VB:

    Media m = new Media(1234);
    string sImgURL= m.getProperty("umbracoFile").Value.ToString();

    #2 - that should be all you need - if it returns # I would suspect there is another problem - maybe the page isn't fully published?  Does it also show "#" if you look at that page's Properties tab next to Link to Document?

    -Tom

  • Bob McLane 19 posts 39 karma points
    Aug 08, 2011 @ 20:27
    Bob McLane
    0

    Tom -

    Ok #1 makes sense. I thought it returned the path but I should be able to figure it out now.

    Regarding #2, yes the page is published. It just occured to me that I need something (web.config?) to tell my local solution where Umbraco is. Is that correct? If so do you know what I need?

     

    Thanks

     

  • Bob McLane 19 posts 39 karma points
    Aug 08, 2011 @ 20:47
    Bob McLane
    0

    For example how do I tell my local visual studio project where umbraco (server) is?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 08, 2011 @ 21:29
    Dirk De Grave
    0

    Bob,

    if you're running this user control from a macro in an umbraco website, then you should be fine with Tom's sample code. So, answer to your original question, if you try to run this from visual studio, you won't get any results except maybe for that '#'.

    If you want to get a media item sitting in an umbraco site but you're not running your code from within umbraco (either as a macro or as plain old .net code), you'd need to reference the umbraco webservices from and make some service calls to get the desired info on the media item.

    All relevant webservices are located in /umbraco/webservices/api directory

    Hope this helps.

    Regards,

    /Dirk

  • Bob McLane 19 posts 39 karma points
    Aug 09, 2011 @ 16:57
    Bob McLane
    0

    Ok I fixed #1 using XPathNodeIterator. Thanks for the help!

    Regarding #2 webservices make sense, I'll try that out.

    My control is up and running. Thanks for all the help!

     

Please Sign in or register to post replies

Write your reply to:

Draft