Exception in template (Designs/Rapido/Paragraph/ParagraphContainer.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.beafcbbfbfccbcfff.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> @using Dynamicweb.Frontend @helper RenderContent(ItemViewModel item, bool isCarousel = false) { string cardClass = item.GetBoolean("ShowAsCard") ? "paragraph-card" : "grid__cell"; cardClass = Pageview.Device.ToString() != "Tablet" ? cardClass : "grid__cell"; if (item.GetList("ContentPositions").SelectedValue == "image-top" || item.GetList("ContentPositions").SelectedValue == "image-centered" || string.IsNullOrEmpty(item.GetList("ContentPositions").SelectedValue)) { <div class="@cardClass"> @RenderImage(item, isCarousel) @RenderHeading(item) @RenderText(item) @RenderModule(item) </div> @RenderButton(item) } if (item.GetList("ContentPositions").SelectedValue == "title-top") { <div class="@cardClass"> @RenderHeading(item) @RenderImage(item, isCarousel) @RenderText(item) @RenderModule(item) </div> @RenderButton(item) } if (item.GetList("ContentPositions").SelectedValue == "image-left") { <div class="grid"> <div class="grid__col-3"> @RenderImage(item, isCarousel) </div> <div class="grid__col-9"> @RenderHeading(item) @RenderText(item) @RenderModule(item) @RenderButton(item) </div> </div> } if (item.GetList("ContentPositions").SelectedValue == "all-centered") { <div class="u-ta-center @cardClass"> @RenderImage(item, isCarousel) @RenderHeading(item) @RenderText(item) @RenderModule(item) </div> @RenderButton(item) } if (item.GetList("ContentPositions").SelectedValue == "middle-center") { <div class="u-ta-center u-middle"> <div class="@cardClass"> @RenderImage(item, isCarousel) @RenderHeading(item) @RenderText(item) @RenderModule(item) </div> @RenderButton(item) </div> } if (item.GetList("ContentPositions").SelectedValue == "middle-left") { <div class="grid__cell u-middle"> <div class="@cardClass"> @RenderImage(item, isCarousel) @RenderHeading(item) @RenderText(item) @RenderModule(item) </div> @RenderButton(item) </div> } } @helper RenderHeading(ItemViewModel item) { if (item.GetBoolean("ShowTitle") != false && !string.IsNullOrEmpty(item.GetString("Title"))) { string headerMargin = item.GetString("Text") != "" && item.GetString("Image") != "" ? "u-margin-bottom" : ""; headerMargin = Model.GetModuleOutput() == "" ? headerMargin : "u-margin-bottom"; string url = item.GetString("Link"); if (!String.IsNullOrEmpty(url)) { <a href="@url"> <h2 class="u-no-margin @headerMargin">@item.GetString("Title")</h2> </a> } else { <h2 class="u-no-margin @headerMargin">@item.GetString("Title")</h2> } } } @helper RenderButton(ItemViewModel item) { string url = item.GetString("Link"); string linkText = item.GetString("LinkText"); string footerCssClass = ""; string cardFooterClass = item.GetBoolean("ShowAsCard") ? "paragraph-card-footer" : "grid__cell-footer"; cardFooterClass = Pageview.Device.ToString() != "Tablet" ? cardFooterClass : ""; if (item.GetList("ContentPositions").SelectedValue == "all-centered" || item.GetList("ContentPositions").SelectedValue == "middle-center") { footerCssClass = "grid--justify-center"; } if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(linkText)) { string buttonStyle = !String.IsNullOrEmpty(item.GetList("ButtonDesign").SelectedValue) ? item.GetList("ButtonDesign").SelectedValue : "primary"; <div class="@footerCssClass @cardFooterClass"> <div class="u-margin-top u-margin-bottom"> @if (url.Contains("http")) { <a href="@url" class="btn btn--@buttonStyle btn--line-height dw-mod" target="_blank">@linkText</a> } else if (url.Contains("/")) { <a href="@url" class="btn btn--@buttonStyle btn--line-height dw-mod" download>@linkText</a> } else { <a href="@url" class="btn btn--@buttonStyle btn--line-height dw-mod">@linkText</a> } </div> </div> } else { <div class="grid__cell-footer @footerCssClass @cardFooterClass"></div> } } @helper RenderText(ItemViewModel item) { if (!string.IsNullOrWhiteSpace(item.GetString("Text"))) { @item.GetString("Text") } } @helper RenderModule(ItemViewModel item) { @Model.GetModuleOutput(); } @helper RenderImage(ItemViewModel item, bool isCarousel) { if (!string.IsNullOrEmpty(item.GetString("Image")) && item.GetList("ImageStyle").SelectedValue != "background") { string url = item.GetString("Link"); <div class="u-margin-bottom"> @if (!String.IsNullOrEmpty(url)) { <a href="@url"> @RenderImageElement(item, isCarousel) </a> } else { @RenderImageElement(item, isCarousel) } </div> } } @helper RenderImageElement(ItemViewModel item, bool isCarousel) { string image = item.GetFile("Image") != null ? System.Web.HttpContext.Current.Server.UrlEncode(item.GetFile("Image").Path) : ""; string altText = item.GetString("Title"); string imgCssClass = ""; string imgCrop = !string.IsNullOrEmpty(item.GetList("ImageCrop").SelectedValue) ? item.GetList("ImageCrop").SelectedValue : "5"; string imageBoxWidth = "480"; int imageWidth = Int32.Parse(item.GetList("Width").SelectedValue) < 8 ? 496 : 992; int imageHeight = Int32.Parse(item.GetList("Width").SelectedValue) < 8 ? 380 : 760; string placeHolderImage = "/Files/Images/placeholder.gif"; if (item.GetList("ContentPositions").SelectedValue == "image-centered" || item.GetList("ContentPositions").SelectedValue == "all-centered" || item.GetList("ContentPositions").SelectedValue == "middle-center") { imgCssClass = "grid__cell-img--centered"; } if (item.GetList("ImageStyle").SelectedValue == "ball") { imgCssClass += " grid__cell-img--ball"; if (!isCarousel) { <img class="grid__cell-img @imgCssClass b-lazy b-loaded" src="/Admin/Public/GetImage.ashx?width=@imageBoxWidth&amp;height=@imageBoxWidth&amp;crop=@imgCrop&amp;Compression=75&amp;DoNotUpscale=true&amp;FillCanvas=true&amp;image=@image" data-src="/Admin/Public/GetImage.ashx?width=@imageBoxWidth&amp;height=@imageBoxWidth&amp;crop=@imgCrop&amp;Compression=75&amp;DoNotUpscale=true&amp;FillCanvas=true&amp;image=@image" alt="@altText"> } else { <img class="grid__cell-img @imgCssClass" src="/Admin/Public/GetImage.ashx?width=@imageBoxWidth&amp;height=@imageBoxWidth&amp;crop=@imgCrop&amp;Compression=75&amp;DoNotUpscale=true&amp;image=@image" alt="@altText"> } } else { string largeImage = "/Admin/Public/GetImage.ashx?width=" + imageWidth + "&amp;height=" + imageHeight + "&amp;crop=" + imgCrop + "&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image=" + image; string smallImage = "/Admin/Public/GetImage.ashx?width=" + imageWidth/2 + "&amp;height=" + imageHeight/2 + "&amp;crop=" + imgCrop + "&amp;Compression=75&amp;DoNotUpscale=true&amp;FillCanvas=true&amp;image=" + image; if (!isCarousel) { <img class="@imgCssClass b-lazy b-loaded" src="@largeImage" data-src="@largeImage" data-src-small="@smallImage" alt="@altText"> } else { <img class="@imgCssClass" src="@largeImage" alt="@altText"> } } } @{ string fontColor = !string.IsNullOrEmpty(Model.Item.GetList("FontColor").SelectedValue) ? "u-" + Model.Item.GetList("FontColor").SelectedValue : ""; string backgroundColor = !string.IsNullOrEmpty(Model.Item.GetList("BackgroundColor").SelectedValue) ? "u-" + Model.Item.GetList("BackgroundColor").SelectedValue + "--bg" : ""; string paragraphContainerClasses = ""; string containerClasses = string.IsNullOrEmpty(Model.Item.GetList("Width").SelectedValue) ? "center-container dw-mod" : ""; string gridClasses = "grid"; string spacingSize = Model.Item.GetList("Spacing") != null && Model.Item.GetList("Spacing").SelectedValue != "" ? Model.Item.GetList("Spacing").SelectedValue : "lg"; int columnCount = 0; int paragraphCount = 0; int totalParagraphs = Model.Item.GetItems("Paragraph").Count; int totalSlides = 1; if (Model.Item.GetList("Width").SelectedValue == "center") { containerClasses = fontColor + " " + backgroundColor + " center-container"; } if (Model.Item.GetList("Width").SelectedValue == "full") { containerClasses = fontColor + " " + backgroundColor; } if (Model.Item.GetList("Width").SelectedValue == "combi") { paragraphContainerClasses = @fontColor + " " + @backgroundColor; containerClasses = "center-container"; } string fullBackgroundImage = ""; if (Model.Item.GetFile("BackgroundImage") != null) { fullBackgroundImage = "background-image:url(/Admin/Public/GetImage.ashx?width=2500&amp;height=1100&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").Path + ");"; fullBackgroundImage += " background-position: center center; background-size: cover; "; } else if (string.IsNullOrEmpty(Model.Item.GetList("BackgroundColor").SelectedValue)) { backgroundColor = "u-color-light--bg"; gridClasses += " "; } if (Model.Item.GetBoolean("SeperationLineAfter") && Model.Item.GetList("Width").SelectedValue != "center") { paragraphContainerClasses += " multiple-paragraphs-container--seperation-line-after"; } else if (Model.Item.GetBoolean("SeperationLineAfter")) { containerClasses += " multiple-paragraphs-container--seperation-line-after"; } gridClasses += !string.IsNullOrEmpty(Model.Item.GetList("Height").SelectedValue) ? " paragraph-container--height-" + Model.Item.GetList("Height").SelectedValue : ""; string containerId = "Paragraph_" + Model.ID; string carouselContainerClass = ""; string carouselSlideClass = ""; //Set as carousel if (Model.Item.GetBoolean("EnableCarousel")) { containerClasses += " carousel js-carousel-container"; carouselContainerClass += "carousel__container dw-mod"; carouselSlideClass += "carousel__container__slide dw-mod"; containerId = "Carousel_" + Model.ID; } } @* Escape the container and section *@ @* Divs count is equal divs in Page.cshtml *@ </div></div></div> </section> @* ----------------------------------- *@ <section class="multiple-paragraphs-container @paragraphContainerClasses multiple-paragraphs-container--spacing-@spacingSize dw-mod" style="@fullBackgroundImage"> <div class="@containerClasses dw-mod" id="@containerId"> <div class="@carouselContainerClass"> <div class="@carouselSlideClass"> <div class="@gridClasses"> @foreach (var paragraph in Model.Item.GetItems("Paragraph")) { int columnWidth = Pageview.Device.ToString() != "Mobile" ? Int32.Parse(paragraph.GetList("Width").SelectedValue) : 12; if (columnCount < 12) { columnCount += columnWidth; } else { columnCount = columnWidth; } string columnCssClasses = "grid__col-md-" + columnWidth + " grid__col-xs-" + paragraph.GetList("WidthMobile").SelectedValue; string backgroundImage = ""; string imageStyle = paragraph.GetList("ImageStyle").SelectedValue; if (paragraph.GetString("WidthMobile") == "hide") { columnCssClasses = "grid__col-md-" + columnWidth + " grid__col-xs--hidden"; } if (imageStyle == "background" && paragraph.GetFile("Image") != null) { columnCssClasses += " grid__col--bg"; string cropMode = paragraph.GetList("ImageCrop").SelectedValue != null ? paragraph.GetList("ImageCrop").SelectedValue : "0"; backgroundImage = "background-image:url(/Admin/Public/GetImage.ashx?width=2500&amp;height=1100&amp;crop=" + cropMode + "&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + paragraph.GetFile("Image").Path + ");"; } <div class="@columnCssClasses paragraph-container" style="@backgroundImage"> @RenderContent(paragraph, Model.Item.GetBoolean("EnableCarousel")) </div> paragraphCount++; if (paragraphCount != totalParagraphs) { string breakMarkup = string.Empty; if (columnCount == 12) { breakMarkup = "</div></div><div class=\"" + carouselSlideClass + "\"><div class=\"" + gridClasses + "\">"; totalSlides++; } @breakMarkup } } </div> </div> </div> @if (Model.Item.GetBoolean("EnableCarousel") && totalSlides > 1) { <div class="js-carousel-data" data-total-slides="@totalSlides" data-carousel-slide-time="@Model.Item.GetString("SlideTime")"> <div class="carousel-prev-btn dw-mod" onclick="Carousel.GetPreviousSlide(this)"></div> <div class="carousel-next-btn dw-mod" onclick="Carousel.GetNextSlide(this)"></div> </div> } </div> </section> @* Re-enter the container and section *@ @* Divs count is equal divs in Page.cshtml *@ <section class="content-container center-container dw-mod"> <div class="grid"> <div class="grid__col-auto grid__col--bleed"> <div class="grid"> @* ----------------------------------- *@