Error executing template "Designs/CapoStarter/Paragraph/C-BlockSection.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_9775370cd6e147fabc871ef625551426.Execute() in E:\Website\Sundqvist_DW9V2_PROD\Files\Templates\Designs\CapoStarter\Paragraph\C-BlockSection.cshtml:line 0
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System 3 @using System.Web 4 @using Dynamicweb.Content.Items 5 @using Dynamicweb.Environment.Web 6 @using Dynamicweb.Frontend 7 8 9 <section class="content-section @Model.Item.GetList("BackgroundColor").SelectedValue @Model.Item.GetList("MarginTop").SelectedValue @Model.Item.GetList("MarginBottom").SelectedValue"> 10 <div class="@Model.Item.GetList("Width").SelectedValue"> 11 12 @if (!string.IsNullOrEmpty(Model.Item.GetString("SectionHeader"))) 13 { 14 <div class="text-center"> 15 <h2 class="content-section-section-header">@Model.Item.GetString("SectionHeader")</h2> 16 </div> 17 } 18 19 <div class="row clearfix"> 20 21 @foreach (var paragraph in Model.Item.GetItems("Blocks")) 22 { 23 @RenderContent(paragraph) 24 } 25 26 </div> 27 </div> 28 </section> 29 30 31 @helper RenderContent(ItemViewModel item) 32 { 33 if (!item.GetBoolean("Hide")) 34 { 35 36 if (item.GetList("TextImagePosition").SelectedValue == "SPECIALContactCTA") 37 { 38 @RenderSPECIALContactCTA(item) 39 } 40 else 41 { 42 <div class="@item.GetList("Width").SelectedValue.Replace(".", " ") banner"> 43 44 @if (item.GetList("TextImagePosition").SelectedValue == "TextBelowImage") 45 { 46 @RenderTextBelowImage(item) 47 } 48 49 @if (item.GetList("TextImagePosition").SelectedValue == "TextBelowImageCentered") 50 { 51 @RenderTextBelowImageCentered(item) 52 } 53 54 @if (item.GetList("TextImagePosition").SelectedValue == "TextLeftOfimage") 55 { 56 @RenderTextLeftOfimage(item) 57 } 58 59 @if (item.GetList("TextImagePosition").SelectedValue == "TextRightOfImage") 60 { 61 @RenderTextRightOfImage(item) 62 } 63 64 @if (item.GetList("TextImagePosition").SelectedValue == "TextFloatingOverImage") 65 { 66 @RenderTextFloatingOverImage(item) 67 } 68 69 </div> 70 } 71 72 73 } 74 } 75 76 @helper RenderSPECIALContactCTA(ItemViewModel item) 77 { 78 <div class="col-xs-12 col-sm-6 col-md-3 col-md-push-1"> 79 <div class="about-us-intro" style="padding:0;"> 80 <div class="sticker"> 81 <i class="fa fa-commenting-o"></i> 82 @RenderText(item) 83 </div> 84 </div> 85 </div> 86 } 87 88 89 @helper RenderTextBelowImageCentered(ItemViewModel item) 90 { 91 <div style="margin: 0 auto; float:none;" class="text-center col-sm-8 col-xs-12"> 92 @RenderImage(item) 93 @RenderText(item) 94 </div> 95 } 96 97 98 @helper RenderTextFloatingOverImage(ItemViewModel item) 99 { 100 string bannerStyle = "banner-sm"; 101 102 if (item.GetList("Width").SelectedValue == "col-sm-12.col-xs-12") 103 { 104 bannerStyle = "banner-lg"; 105 } 106 107 if (item.GetList("Width").SelectedValue == "col-sm-6.col-xs-12") 108 { 109 bannerStyle = "banner-md"; 110 } 111 112 if (item.GetFile("Image") != null) 113 { 114 string imageMobile = HttpUtility.UrlPathEncode(item.GetFile("Image").Path); 115 116 if (item.GetFile("Image_Mobile") != null) 117 { 118 imageMobile = item.GetFile("Image_Mobile").Path; 119 } 120 <div class="@bannerStyle"> 121 <div class="thumbnail medium-banner Y-animate"> 122 <div class="img-wrapp"> 123 <div class="img-inner"> 124 <picture> 125 @if (bannerStyle == "banner-md") 126 { 127 128 <!--[if IE 9]><audio><![endif]--> 129 <source srcset="/admin/public/getimage.ashx?Image=@HttpUtility.UrlPathEncode(item.GetFile("Image").Path)&Format=jpg&Compression=70&width=560&crop=0&altFmImage_path=/Files/Images/NoImageAvailable.png" class="img-responsive" alt="" media="(min-width: 900px)"> 130 <!--[if IE 9]></audio><![endif]--> 131 <img src="/admin/public/getimage.ashx?Image=@imageMobile&Format=jpg&Compression=70&width=560&crop=0&altFmImage_path=/Files/Images/NoImageAvailable.png" class="img-responsive" srcset="" alt=""> 132 } 133 else 134 { 135 <!--[if IE 9]><audio><![endif]--> 136 <source srcset="/admin/public/getimage.ashx?Image=@HttpUtility.UrlPathEncode(item.GetFile("Image").Path)&Format=jpg&Compression=70&width=1550&crop=0&altFmImage_path=/Files/Images/NoImageAvailable.png" class="img-responsive" alt="" media="(min-width: 900px)"> 137 <!--[if IE 9]></audio><![endif]--> 138 <img src="/admin/public/getimage.ashx?Image=@imageMobile&Format=jpg&Compression=70&width=560&crop=0&altFmImage_path=/Files/Images/NoImageAvailable.png" class="img-responsive" srcset="" alt=""> 139 } 140 141 </picture> 142 </div> 143 </div> 144 @RenderText(item) 145 </div> 146 </div> 147 } 148 } 149 150 151 152 @helper RenderTextBelowImage(ItemViewModel item) 153 { 154 155 bool renderBlockTextPart = true; 156 string removeMarginBottom = string.Empty; 157 158 @* When both title and text is empty dont render bottom part - otherwise it becomes a big white space*@ 159 if (string.IsNullOrEmpty(item.GetString("Title")) && string.IsNullOrEmpty(item.GetString("Description"))) 160 { 161 renderBlockTextPart = false; 162 removeMarginBottom = "style=\"margin-bottom:0;\""; 163 } 164 165 <div class="thumbnail display-box Y-animate" @removeMarginBottom> 166 @if (!string.IsNullOrEmpty(item.GetString("Youtube_URL"))) 167 { 168 @RenderYoutube(item) 169 } 170 else 171 { 172 @RenderImage(item) 173 } 174 175 @if (renderBlockTextPart) 176 { 177 @RenderText(item) 178 } 179 </div> 180 } 181 182 183 @helper RenderTextLeftOfimage(ItemViewModel item) 184 { 185 <div class="row clearfix TextSideOfimage"> 186 <div class="col-sm-6 col-md-5 img text-left TextSideOfimage-img"> 187 @RenderImage(item) 188 </div> 189 <div class="col-sm-6 col-md-7 TextSideOfimage-text"> 190 <div class="text-left TextSideOfimage-inner"> 191 @RenderText(item) 192 </div> 193 </div> 194 </div> 195 } 196 197 @helper RenderTextRightOfImage(ItemViewModel item) 198 { 199 if (Pageview.Device.ToString() != "Mobile") 200 { 201 <div class="row clearfix TextSideOfimage text-inside"> 202 <div class="col-sm-6 col-md-7 TextSideOfimage-text"> 203 <div class="text-left TextSideOfimage-inner"> 204 @RenderText(item) 205 </div> 206 </div> 207 <div class="col-sm-6 col-md-5 img text-right TextSideOfimage-img"> 208 @RenderImage(item) 209 </div> 210 </div> 211 } 212 213 if (Pageview.Device.ToString() == "Mobile") 214 { 215 <div class="row clearfix TextSideOfimage text-inside"> 216 <div class="col-sm-6 col-md-5 img text-right TextSideOfimage-img"> 217 @RenderImage(item) 218 </div> 219 <div class="col-sm-6 col-md-7 TextSideOfimage-text"> 220 <div class="text-left TextSideOfimage-inner"> 221 @RenderText(item) 222 </div> 223 </div> 224 </div> 225 } 226 } 227 228 229 230 231 @helper RenderImage(ItemViewModel item) 232 { 233 if (item.GetFile("Image") != null) 234 { 235 string wrapLinkStart = string.Empty; 236 string wrapLinkEnd = string.Empty; 237 238 if (string.IsNullOrEmpty(item.GetString("LinkText")) && !string.IsNullOrEmpty(item.GetString("URL"))) 239 { 240 wrapLinkStart = "<a href=\"" + @item.GetString("URL") + "\">"; 241 wrapLinkEnd = "</a>"; 242 } 243 244 @wrapLinkStart 245 <div class="display-img img-wrapp"> 246 <div class="img-inner"> 247 <img src="/admin/public/getimage.ashx?Image=@HttpUtility.UrlPathEncode(item.GetFile("Image").Path)&Format=jpg&Compression=70&height=500&width=1150&crop=5&altFmImage_path=/Files/Images/NoImageAvailable.png" class="img-responsive" alt="..."> 248 </div> 249 </div> 250 @wrapLinkEnd 251 252 } 253 } 254 255 256 @helper RenderYoutube(ItemViewModel item) 257 { 258 string youtubeVId = string.Empty; 259 if (item.GetString("Youtube_URL").Contains("?v=")) 260 { 261 var tempArr = item.GetString("Youtube_URL").Split('='); 262 youtubeVId = tempArr[1]; 263 } 264 var videoThumb = "http://img.youtube.com/vi/" + youtubeVId + "/0.jpg"; 265 266 <a class="y-video" data-video="@item.GetString("Youtube_URL")" data-toggle="modal" data-target="#videoModal"> 267 <div class="display-img img-wrapp"> 268 <div class="img-inner youtube"> 269 <img src="@videoThumb" class="img-responsive" alt="..."> 270 </div> 271 </div> 272 </a> 273 } 274 275 276 @helper RenderText(ItemViewModel item) 277 { 278 string TextClasses = string.Empty; 279 string wrapLinkStart = string.Empty; 280 string wrapLinkEnd = string.Empty; 281 string buttonLink = string.Empty; 282 string startHeaderTag = "<" + item.GetList("HeaderStyle").SelectedValue + ">"; 283 string endHeaderTag = "</" + item.GetList("HeaderStyle").SelectedValue + ">"; 284 285 if (item.GetList("TextImagePosition").SelectedValue == "TextBelowImage" || item.GetList("TextImagePosition").SelectedValue == "TextFloatingOverImage") 286 { 287 TextClasses = "caption display-caption caption-wrapp"; 288 } 289 290 if (string.IsNullOrEmpty(item.GetString("LinkText")) && !string.IsNullOrEmpty(item.GetString("URL"))) 291 { 292 wrapLinkStart = "<a href=\"" + @item.GetString("URL") + "\">"; 293 wrapLinkEnd = "</a>"; 294 } 295 if (!string.IsNullOrEmpty(item.GetString("LinkText")) && !string.IsNullOrEmpty(item.GetString("URL"))) 296 { 297 buttonLink = "<a class=\"banner-link\" href=\"" + @item.GetString("URL") + "\">" + @item.GetString("LinkText") + "</a>"; 298 } 299 if (item.GetBoolean("DownloadImageLink") && item.GetFile("Image") != null) 300 { 301 buttonLink = "<a class=\"banner-link\" href=\"/admin/public/getimage.ashx?Image=" + HttpUtility.UrlPathEncode(item.GetFile("Image").Path) + "&Format=jpg&Width=10000&Compression=100&DoNotUpscale=True&ForceDownload=True\">" + Translate("DownloadLink", "Download") + "</a>"; 302 } 303 304 <text> 305 @wrapLinkStart 306 <div class="@TextClasses @item.GetList("BlockContentAlignment").SelectedValue"> 307 @startHeaderTag @item.GetString("Title") @endHeaderTag 308 <p>@item.GetString("Description")</p> 309 @buttonLink 310 </div> 311 @wrapLinkEnd 312 </text> 313 314 }

Meny