Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    Feb 05, 2014 @ 13:40
    René Andersen
    0

    On every children +1 (count)

    Hi

    In the code below i need it to +1 on every children on data-slide-index="0".

    Starting at 0 and then 1,2,3,4,5

    @foreach (var image in @Model.Children)
    {
    foreach (dynamic d in image.imageDampSingle)
    {
    <a data-slide-index="0" href="@DAMP_Helper.GetImageCropperUrl(d, "projectSingle")"><img src="@DAMP_Helper.GetImageCropperUrl(d, "projectSingleThumb")" title="@Model.captionText" alt="@d.Image.nodeName" /></a>

    Thanks in advance!

    Kind regards

    René

  • Marcio Goularte 356 posts 1248 karma points
    Feb 05, 2014 @ 13:57
    Marcio Goularte
    0

    Hi,

    Use the property Position

    @foreach(var image in@Model.Children)
    {
    foreach(dynamic d in image.imageDampSingle)
    {
    <a data-slide-index="@d.Position" href="@DAMP_Helper.GetImageCropperUrl(d, "projectSingle")"><img src="@DAMP_Helper.GetImageCropperUrl(d, "projectSingleThumb")" title="@Model.captionText" alt="@d.Image.nodeName"/></a>
  • René Andersen 238 posts 684 karma points
    Feb 05, 2014 @ 14:14
    René Andersen
    0

    Hi Marcio

    I have just tried that with no luck. Am I missing something?

    René

  • René Andersen 238 posts 684 karma points
    Feb 05, 2014 @ 14:27
    René Andersen
    0

    I was thinking something like this.

    int theCount = 0;
    theCount += 1; // Adds 1 to count

    But I dont know how to use it correctly in the code.

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Feb 05, 2014 @ 14:31
    Dennis Aaen
    0

    Hi René

    Could you try this one:

    @foreach(var image in Model.Children)
    {
    foreach(dynamic d in image.imageDampSingle)
    {
    <a data-slide-index="@d.Position()" href="@DAMP_Helper.GetImageCropperUrl(d, "projectSingle")"><img src="@DAMP_Helper.GetImageCropperUrl(d, "projectSingleThumb")" title="@Model.captionText" alt="@d.Image.nodeName"/>a>

    /Dennis

  • René Andersen 238 posts 684 karma points
    Feb 06, 2014 @ 10:10
    René Andersen
    0

    Hi Dennis

    Unfortunately that did not work either. Someone asked me if it could be made by using recursion. Does that mean anything to you?

    // René

  • René Andersen 238 posts 684 karma points
    Feb 06, 2014 @ 13:25
    René Andersen
    100

    I finally found a solution myself. See below:

    @{
    var countNum = -1;
    }
    @foreach (var image in @Model.Children)
    {
    {
    countNum += 1;
    }
    foreach (dynamic d in image.imageDampSingle)
    {
    <a data-slide-index="@countNum" href="@DAMP_Helper.GetImageCropperUrl(d, "projectSingle")"><img src="@DAMP_Helper.GetImageCropperUrl(d, "projectSingleThumb")" title="@Model.captionText" alt="@d.Image.nodeName" /></a>
    }
    }

    // René

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies