Copied to clipboard

Flag this post as spam?

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


  • JimBob SquarePants 3 posts 23 karma points
    Apr 20, 2011 @ 14:26
    JimBob SquarePants
    0

    Is it me or is it Umbraco?

    I'm having a hell of a time getting something which should be simple to work. Is there something simple i've missed or are there bugs in Umbraco's Razor parser?

    Carousel.cshtml(35): error CS0117: 'umbraco.item' does not contain a definition for 'linkText'

    @
    CAROUSEL MACRO
    =======================

    Creates and displays the carousel.

    *@
    @{
      var carousel @Model.Descendants("carousel").FirstOrDefault();
      string itemCount umbraco.library.GetPreValueAsString(@carousel.itemCount);
      string cssClass;
      
      if (carousel != null)
      {
        if (itemCount == "3 item")
        {
         cssClass "col w634";
        }
        else
        {
         cssClass "col w880 bgPanel3 pt40 pr40 pl40 pb40";
        }
       
         <div class="@cssClass"
            <div class="rv_gallery carousel">
               <div class="rv_strip_wrapperh h230 wrapper" >
                 <div class="slider h230 clearfix">
                     foreach (var item in @Model.Descendants("carouselItem").Where("visible"))
                     {
                       <div class="item">
                         <class="carouselItemLink" href="#"></a>
                           <div class="promoFrame promoFrame160">
                             <div class="promoFrameFrame"></div>
                             <div class="promoFrameImage">
                               <img alt="@item.linkText" src="@item.image">
                             </div>                                                
                           </div>
                           <class="arrowLink" href="#">item.linkText</a>
                       </div>      
                     }
                 </div>
               </div>
            </div>
        </div>
       
       }
     
      }

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Apr 20, 2011 @ 17:10
    Sebastiaan Janssen
    0

    First of all, is there a property on the carouselItem documentType that has an alias of "linkText"? 

    You could try to do a "dynamic item" instead of "var item", I haven't tested your code so that might not help. :-)

  • JimBob SquarePants 3 posts 23 karma points
    Apr 20, 2011 @ 17:31
    JimBob SquarePants
    0

    Thanks for the reply..... I've just managed to solve the issu now but it looks like a bug to me.

    If I move the closing bracket from around the entire code block and place it under the initializers like thus. The code works..... weird.

    @{
      var carousel @Model.Descendants("carousel").FirstOrDefault();
      string itemCount umbraco.library.GetPreValueAsString(@carousel.itemCount);
      string cssClass;

    }

Please Sign in or register to post replies

Write your reply to:

Draft