Exception in template (Designs\Martin\eCom/Productlist/Martin_v3_ProductList_USE.cshtml): System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
   at System.String.Substring(Int32 startIndex, Int32 length)
   at CompiledRazorTemplates.Dynamic.cbabdfabbbeb.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
<div class="pageContent productList"> <div> <div class="sectionHeader"> <div class="container"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 marginTop"> <h2 id="navReferences" class="black"> @GetValue("Ecom:Group.Name") </h2> </div> </div><!-- end container --> </div><!-- end sectionHeader --> <div class="container"> <div class="sixteen columns"> <!-- If there is a subgroup --> <section class="group-list product-list productList" > @foreach (LoopItem i in GetLoop("Subgroups")){ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 reference group-item product-item mod-@i.GetValue("Subgroups.LoopMod4")"> <a class="prodLink" href="@i.GetValue("Ecom:Group.Link.Clean")"> <img class="lazy" src="/files/templates/designs/martin/images/ajax-loader.gif" data-original="/admin/public/getimage.ashx?Image=@i.GetValue("Ecom:Group.LargeImage")&width=148&Compression=90&Format=jpg&Crop=5"> </a> <h3 class="category"><a href="@i.GetValue("Ecom:Group.Link.Clean")">@i.GetValue("Ecom:Group.Name")</a></h3> </div> } </section> </div> </div><!-- end container--> </div> <div> <div class="container productList" id="productList"> @{ string dayTodayToDate = @GetGlobalValue("Global:Server.Date").ToString(); string dayTodayToTime = @GetGlobalValue("Global:Server.Date.ShortTime").ToString(); } @foreach(LoopItem i in GetLoop("Products")) { // string productStatus = i.GetValue("Ecom:Product:Field.ProductStatus").ToString(); int productStatus = Convert.ToInt32(i.GetValue("Ecom:Product:Field.ProductStatus")); string goLiveDate = @i.GetValue("Ecom:Product:Field.ProductGoLiveDate").ToString(); <h1></h1> string goLiveDay = @goLiveDate.Substring(0,2); string goLiveMonth = @goLiveDate.Substring(3,2); string goLiveYear = @goLiveDate.Substring(6,4); string goLiveTime = @goLiveDate.Substring(10,6); var goLiveDateCombined = @goLiveMonth + "/" + @goLiveDay + "/" + @goLiveYear; string goLiveDateCombinedTrim = @goLiveDateCombined.ToString(); <h1> </h1> DateTime dtGoLive = DateTime.Parse(goLiveDateCombined); DateTime dtTimeNow = DateTime.Parse(dayTodayToDate); DateTime dtGoLiveTime = DateTime.Parse(goLiveTime); DateTime dtTimeNowTime = DateTime.Parse(dayTodayToTime); <h1></h1> <h1></h1> if(dtTimeNow.Date > dtGoLive.Date) { if(@productStatus > 1) { <article class="col-lg-4 col-md-4 col-sm-4 col-xs-12 product-item mod-@i.GetValue("Products.LoopMod4")" style="position: relative;"> <a class="prodLink" href="@i.GetValue("Ecom:Product.Link.Clean")" style=""> @if(@productStatus == 1) { <div>Discontinued</div> } @if(@productStatus == 2) { <img src="/files/templates/designs/martin/images/productList/comingsoon_sticker.png" alt="" style="position: absolute; top: 0%; left: 0; width: 50%; height: auto;" /> } <img class="" data-original="" src="/admin/public/getimage.ashx?Image=@i.GetValue("Ecom:Product.ImageMedium.Clean")&width=250&Compression=90&Format=jpg&Crop=5" /> </a> <h3 class="category"><a href="@i.GetValue("Ecom:Product.Link.Clean")">@i.GetValue("Ecom:Product.Name")</a></h3> </article> } } <!-- <h1>dayTodayToDate = @dayTodayToDate AND goLiveDateCombined = @goLiveDateCombined </h1> --> if(dayTodayToDate == goLiveDateCombinedTrim){ if(dtTimeNowTime.TimeOfDay > dtGoLiveTime.TimeOfDay ) { if(@productStatus > 1) { <article class="col-lg-4 col-md-4 col-sm-4 col-xs-12 product-item mod-@i.GetValue("Products.LoopMod4")" style="position: relative;"> <a class="prodLink" href="@i.GetValue("Ecom:Product.Link.Clean")" style=""> @if(@productStatus == 1) { <div>Discontinued</div> } @if(@productStatus == 2) { <img src="/files/templates/designs/martin/images/productList/comingsoon_sticker.png" alt="" style="position: absolute; top: 0%; left: 0; width: 50%; height: auto;" /> } <img class="" data-original="" src="/admin/public/getimage.ashx?Image=@i.GetValue("Ecom:Product.ImageMedium.Clean")&width=250&Compression=90&Format=jpg&Crop=5" /> </a> <h3 class="category"><a href="@i.GetValue("Ecom:Product.Link.Clean")">@i.GetValue("Ecom:Product.Name")</a></h3> </article> } } } } </div> </div> </div> <script> $(document).ready(function(){ if($.trim($(".group-list").html())=='') { $('.group-list').hide(); } if($('.reference').length > 1) { $('.productList').hide(); } }); </script> <style> body { background: #fff; } #blankContent { background: #fff; } .product-item:hover .category a { } </style> <script src="/files/templates/designs/martin/js/productpageJs.js" async></script>