Exception in template (Designs/Partnerejendomme/Paragraph/Project_List.cshtml): System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
at System.String.Remove(Int32 startIndex, Int32 count)
at CompiledRazorTemplates.Dynamic.ebfeeebebffedbc.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()
@using System.Web
@{
var projects = GetLoop("Item.Projects");
string queryString = HttpContext.Current.Request.QueryString["itemId"]!=null ? HttpContext.Current.Request.QueryString["itemId"].ToString() : string.Empty;
var url = GetGlobalValue("Global:Pageview.Url");
string pageUrl = "/Default.aspx?ID="+GetGlobalValue("Global:Page.ID");
}
@foreach(var project in projects){
int id = project.GetInteger("Item.Projects.Id");
string title = !string.IsNullOrWhiteSpace(project.GetString("Item.Projects.Title")) ? project.GetString("Item.Projects.Title") : project.GetString("Item.Projects.ParagraphName");
int counter = project.GetInteger("Item.Projects.LoopCounter");
if(!string.IsNullOrEmpty(queryString)){
if(queryString == "Project:"+id){
var slider = project.GetLoop("Item.Projects.Slides");
string content_headline = project.GetString("Item.Projects.Headline");
string content_text = project.GetString("Item.Projects.Content");
string externalLink = project.GetString("Item.Projects.Link");
string prevPage = string.Empty;
string nextPage = string.Empty;
int place = url.LastIndexOf(queryString);
int prevId = id==1 ? projects.Count : id-1;
int nextId = id==projects.Count ? 1 : id+1;
prevPage = url.Remove(place, queryString.Length).Insert(place, "Project:"+prevId);
nextPage = url.Remove(place, queryString.Length).Insert(place, "Project:"+nextId);
<div class="col-xs-12">
@if(!string.IsNullOrWhiteSpace(title)){
<h1 class="project-title">@title</h1>
}
<div class="project-nav">
<a href="@pageUrl" class="project-button project-button-overview btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span> Oversigten</a>
<a href="@prevPage" class="project-button project-button-prev btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span></a>
<a href="@nextPage" class="project-button project-button-next btn btn-default"><span class="glyphicon glyphicon-arrow-right"></span></a>
</div>
@if(slider.Count>0){
var sliderListId = string.Format("bxslider-{0}", id);
var sliderContainerId = string.Format("sliderFrame-{0}", id);
<div class="imageSliderContainer" id="@sliderContainerId">
<div class="sliderFrame">
<ul class="bxslider" id="@sliderListId">
@for(var i = 0; slider.Count > i; i++){
var item = slider[i];
var imageUrl = item.GetValue("Item.Projects.Slides.Baggrundsbillede");
string imageslider_Link = item.GetString("Item.Projects.Slides.Link");
string overskrift = item.GetString("Item.Projects.Slides.Overskrift");
string tekst = item.GetString("Item.Projects.Slides.Tekst");
string statement = item.GetString("Item.Projects.Slides.Statement");
string imgAlt = item.GetString("Item.Projects.Slides.Alt_tekst");
string onClick = string.Empty;
string mouseStyle = string.Empty;
if(!string.IsNullOrEmpty(imageslider_Link)){
onClick="location.href='/"+imageslider_Link+"'";
mouseStyle="cursor:pointer;";
}
<li class="sliderItem" onclick="@onClick" style="@mouseStyle">
<img src="@imageUrl" alt="@imgAlt" />
@if(!string.IsNullOrEmpty(statement)){
<div class="bx-statement">
<h1>@statement</h1>
</div>
}
@if((!string.IsNullOrEmpty(overskrift) || !string.IsNullOrEmpty(tekst))){
<div class="bx-caption">
<h2>@overskrift</h2>
<p>@tekst</p>
</div>
}
</li>
}
</ul>
</div>
</div>
<script>
$(document).ready(function(){
if(boxSlider == undefined){
boxSlider = [{sliderList:'#@sliderListId', slideOptions: {captions: "true", auto: @(slider.Count>1 ? "true" : "false"), pager: @(slider.Count>1 ? "true" : "false")}}];
} else {
boxSlider.push({sliderList:'#@sliderListId', slideOptions: {captions: "true", auto: @(slider.Count>1 ? "true" : "false"), pager: @(slider.Count>1 ? "true" : "false")}});
}
});
</script>
}
@if(!string.IsNullOrWhiteSpace(content_headline)){
<h2>@content_headline</h2>
}
@if(!string.IsNullOrWhiteSpace(content_text)){
<text>@content_text</text>
}
@if(!string.IsNullOrWhiteSpace(externalLink)){
<a href="@externalLink" target="_blank">Besøg @title</a>
}
</div>
break;
}
}
else{
string overView_imagePath = project.GetString("Item.Projects.Overview_Image");
string overView_text = project.GetString("Item.Projects.Overview_Text");
string overView_url = project.GetString("Item.Projects.DetailsUrl");
string overView_link = project.GetString("Item.Projects.Overview_Link");
string projectListElementClass = "col-xs-12 col-sm-6 col-md-4 project-list-element";
projectListElementClass += (counter-1)%3==0 ? " clear-fix" : "";
<div class="@projectListElementClass" onclick="location.href='@(!string.IsNullOrWhiteSpace(overView_link) ? overView_link : overView_url)'">
<h3>@title</h3>
<img src="@overView_imagePath"/>
<p class="overview_Text">@overView_text</p>
<p class="readMore btn btn-default">Læs mere</p>
</div>
}
}