Copied to clipboard

Flag this post as spam?

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


  • Jhon 87 posts 161 karma points
    Apr 24, 2018 @ 12:55
    Jhon
    0

    Error code

    Hi

    i have written this code. It is displying some error.

    see i attached template code because i am passing some values, see blow.

    enter image description here

    see below code

    enter image description here

    see error enter image description here

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Apr 24, 2018 @ 12:57
    Alex Skrypnyk
    0

    Hi Jhon

    Please, do not use images with code - it's hard to help you.

    Share code as code, please.

    Thanks,

    Alex

  • Jhon 87 posts 161 karma points
    Apr 24, 2018 @ 12:59
    Jhon
    0

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{ int bannerNumber = Convert.ToInt32(@Parameter.bannerNum); //var banner1 = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "Banner"); var banner1 = Umbraco.TypedContent(1313).Children.OrderBy("UpdateDate desc").Skip(bannerNumber).First();

    }

    @foreach (var banner in banner1) {
    var link = banner.GetPropertyValue<IPublishedContent>("link");
    <div class="bannersRow">
        <div class="widthContent">  
            <div class="innerbanner1">
                <div id="mediaBlock">
                image   
                </div>
                    <div style="clear:both;"></div>
                    <div id="textBlock">
                    @{  
    
    
                if (link != null) 
                    {
                    <a href="@link.Url" style="color: black">
                       <h1 class="banner1Title">@banner.GetPropertyValue("title")</h1>
                       <h2 class="banner1Subtitle">@banner.GetPropertyValue("subtitle")</h2>
                       </a>
                    }
                    else {
                        <h1 class="banner1Title">@banner.GetPropertyValue("title")</h1>
                         <h2 class="banner1Subtitle">@banner.GetPropertyValue("subtitle")</h2>
                        }
    
                    <div style="clear:both;"></div>
                    }
    
                    Coming Soon
    
                <div style="clear:both;"></div>
    
                </div>
            </div>
        </div>
    </div>
    

    }

  • Michaël Vanbrabandt 863 posts 3343 karma points c-trib
    Apr 24, 2018 @ 13:01
    Michaël Vanbrabandt
    0

    Hi Jhon,

    you can remove the @ in front of the @Parameter object because you are already in a razor section using the @{ ... }.

    Hope this helps!

    /Michaël

  • Jhon 87 posts 161 karma points
    Apr 24, 2018 @ 13:03
    Jhon
    0

    In the template file , i am passing value like that.

    @Html.Partial("BannerRow", new { bannerNum = 0 })

    yes i removed @ , it is displaying same error

  • Jhon 87 posts 161 karma points
    Apr 24, 2018 @ 13:04
    Jhon
    0

    Yes, i removed , it is displying same error enter image description here

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Apr 24, 2018 @ 13:06
    Alex Skrypnyk
    0

    Jhon

    Use this code:

    int bannerNumber = (int)ViewData["bannerNum"];
    
  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Apr 24, 2018 @ 13:07
    Alex Skrypnyk
    0

    and code for rendering partial:

    Html.RenderPartial(
            "~pathToPartial",
            currentNode,
            new ViewDataDictionary(this.ViewData) {
                { "bannerNum", 0 }
            }
        );
    
  • Jhon 87 posts 161 karma points
    Apr 24, 2018 @ 13:16
    Jhon
    0

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{ int bannerNumber = (int)ViewData["bannerNum"];

    Html.RenderPartial(
        "~pathToPartial",
        currentNode,
        new ViewDataDictionary(this.ViewData) {
            { "bannerNum", 0 }
        }
    );
    //var banner1 = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "Banner");
    var banner1 = Umbraco.TypedContent(1313).Children.OrderBy("UpdateDate desc").Skip(bannerNumber).First();
    

    }

    @foreach (var banner in banner1) {
    var link = banner.GetPropertyValue<IPublishedContent>("link");
    <div class="bannersRow">
        <div class="widthContent">  
            <div class="innerbanner1">
                <div id="mediaBlock">
                image   
                </div>
                    <div style="clear:both;"></div>
                    <div id="textBlock">
                    @{  
    
    
                if (link != null) 
                    {
                    <a href="@link.Url" style="color: black">
                       <h1 class="banner1Title">@banner.GetPropertyValue("title")</h1>
                       <h2 class="banner1Subtitle">@banner.GetPropertyValue("subtitle")</h2>
                       </a>
                    }
                    else {
                        <h1 class="banner1Title">@banner.GetPropertyValue("title")</h1>
                         <h2 class="banner1Subtitle">@banner.GetPropertyValue("subtitle")</h2>
                        }
    
                    <div style="clear:both;"></div>
                    }
    
                    Coming Soon
    
                <div style="clear:both;"></div>
    
                </div>
            </div>
        </div>
    </div>
    

    }

    See error: enter image description here

  • Jhon 87 posts 161 karma points
    Apr 26, 2018 @ 07:11
    Jhon
    0

    Can you please help me.

  • 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