Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > How to use GetImage or DocumentURL in a user control View modes: 
User avatar
Member
Member
Jason - 5/4/2011 2:26:20 AM
   
How to use GetImage or DocumentURL in a user control
Hi all,
I am using a custom User Control in my project. I would like to show an image from the CMS system. I use the setting "store images on the file system"
My user Control gets some data from one of my custom doc types which has an image field in it which contains the guid.

How Would I display my image in the user control. I am trying this:



Dim objImgHelper As New CMS.Controls.CMSAbstractTransformation
Dim sReturnImagePath As String = String.Empty
sReturnImagePath = objImgHelper.GetDocumentUrl(sHotelImage) '<-- this is the image GUID

Return sReturnImagePath



Thanks

Jason

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/4/2011 6:06:59 AM
   
RE:How to use GetImage or DocumentURL in a user control
Hi Jason,


Do you want to display a document type field? If so and you know GUID, you can get the URL like:

Guid existingGuid = ValidationHelper.GetGuid(node.GetValue("<field name>"), Guid.Empty);

CMS.FileManager.AttachmentURLProvider.GetAttachmentUrl(existingGuid, nodeAlias)

Does it help?


Best regards,
Helena Grulichova

User avatar
Member
Member
Jason - 5/9/2011 4:12:52 PM
   
RE:How to use GetImage or DocumentURL in a user control
Hello,
thank you for your help it worked fine.

Sorry for not letting you know sooner, I have been busy this week.
Many Thanks

Jason