Copied to clipboard

Flag this post as spam?

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


  • Greyhound 102 posts 124 karma points
    May 16, 2011 @ 13:45
    Greyhound
    0

    Listing contents of a folder in c# asp.net user control

    Hi,

    I'm setting up a gallery. So far I have create a page and added a folder.

    Using DAMP, I have uploaded multiple images to the folder.

    I was expecting to be able to loop through the images contained in the folder by accessing the children but this doesnt seem to work.

    Could someone please point me in the right direction of how to obtain a list of images contained in the folder using c#?

    Thanks in advance.

  • Rich Green 2246 posts 4008 karma points
    May 16, 2011 @ 13:59
    Rich Green
    0

    Is there a reason you're not doing this in XSLT?

    There's a sample XSLT file on the project page here http://our.umbraco.org/projects/backoffice-extensions/digibiz-advanced-media-picker

      <!--In "classic" only 1 id can be stored.-->
      Classic:<br/><br/>
      <img src="{umbraco.library:GetMedia($currentPage/classic, 0)/umbracoFile}" height="150px;" />
    
      <br/><br/>
    
      <!--In "new" multiple media items can be stored with the full media xml.-->
      New:<br/><br/>
      <xsl:for-each select="$currentPage/new/DAMP[@fullMedia]/mediaItem/Image">
        <img src="{umbracoFile}" height="150px;"/>
        <br/>
        <br/>
      </xsl:for-each>
  • Greyhound 102 posts 124 karma points
    May 16, 2011 @ 14:06
    Greyhound
    0

    No reason other than that I prefer to work in user controls and C#.

    I'd basically be looking for a C# representation of the above select statement.

    Cheers,

  • Phil 12 posts 32 karma points
    May 16, 2011 @ 15:05
    Phil
    0

    Not sure if it's good practice, but personally I think I'd write an xslt extension library (annotated class) and use it to return an xml encoded list, then use xslt to cycle through it.

  • Rich Green 2246 posts 4008 karma points
    May 16, 2011 @ 15:13
    Rich Green
    0

    Hey Greyhound,

    Sorry to reply with more questions, but c# and usercontrols seem a little overkill here.

    Have you considered trying Razor?

    Rich

  • Greyhound 102 posts 124 karma points
    May 16, 2011 @ 15:14
    Greyhound
    0

    I'm not sure about an annotated class or what that is. The gallery would have internal controls and be returning ids in the querystring so I would like to use a .net control as I am comfortable in doing things that way.

    Does anyone know the equivalent c# format for the following statement:

    <xsl:for-each select="$currentPage/new/DAMP[@fullMedia]/mediaItem/Image">

  • Greyhound 102 posts 124 karma points
    May 16, 2011 @ 18:07
    Greyhound
    0

    Ok, I've spent a few hours with Razor and it seems to be the way to go. I'm really stuck though on how to pull out the images I need.

    I'm in a bit of a mess here so will outline the situation again in the hope that someone can let me know whether this is possible or not.

    I've created 2 document types.

    1 is for a page template
    2 is a regular folder to sit under the page template

    There can be many folders, as each one will represent a gallery.

    I've added the DAMP multi upload to folders and am picking items uploaded in bulk to a media folder.

    I'm doing it this way so that the images are easily re-sortable in the document content folder.

    What I need to do now is:

    1. Loop through the images that have been chosen for the folder
    2. Get the reference of a larger image version contained in a media folder (by name)

    In short have a solution for me to add thumbnails, be able to easily re-order the thumbnails then be able to link the thumbnails up with larger image versions contained in a media folder.

    Maybe this isnt possible or I've spent the day looking at this the wrong way around but I'm at the end of my tether!!!

    Cheers

  • Rich Green 2246 posts 4008 karma points
    May 16, 2011 @ 18:36
    Rich Green
    0

    Hey Greyhound,

    It's perfectly possible.

    First I would post a snapshot picture of your content structure, so we can see what you're trying to do.

    Rich

     

  • Greyhound 102 posts 124 karma points
    May 16, 2011 @ 18:50
    Greyhound
    0

    Hi Rich,

    Ok, hopefully this will clear it up a bit, let me know if I've missed anything.

    First the media folders:

    The gallery here is under Events, the Gallery name is Centrepieces and there are two folders - one for thumbnails and the other for the larger image versions.
    What I plan to do is to have the thumbnails displayed and then when a user clicks on one there will be a JQuery script that fades in the larger image in a neighbouring DIV layer.

     

    Next is the actual content structure:

    Here I have one folder into which I have chosen a couple of thumbnails. There will be multiple galleries so I've gotten as far as listing out the gallery name on the page. In this case it is Centrepieces but there could be any amount of seperate Folders which represent galleries and hold images.

    What I would like is to be able to list the images which will all be thumbnails and then link these to larger versions. The larger versions will not be in a content folder, the only reason the thumbs need to be in there is so that easy sorting can be carried out and to get the initial list of thumbs (I'm going to implement paging as well as there will only be a set number of thumbs per page)

     

     

Please Sign in or register to post replies

Write your reply to:

Draft