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 AsString = 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 AsInteger = 1158
Dim sNavURL AsString = library.NiceUrl(Me.m_iNavigateNodeID).ToString()
#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?
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?
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
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?
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
Yes the Public Property is Integer. I also attempted to hard code the value with the ID and got back the same result.
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:
#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
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
For example how do I tell my local visual studio project where umbraco (server) is?
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
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!
is working on a reply...