Error compiling template "/Designs/Forslag_01/Paragraph/Banner.cshtml"
Line 488: Unexpected character '\'
Line 488: Too many characters in character literal
Line 488: Unexpected character '\'
Line 497: Unexpected character '\'
Line 497: Unexpected character '\'

1 2 @using System.Text.RegularExpressions 3 @using System.Web 4 5 6 @functions{ 7 public class WrapMethods 8 { 9 //Gets the contrasting color 10 public static string getContrastYIQ(string hexcolor) 11 { 12 if (hexcolor != "") 13 { 14 hexcolor = Regex.Replace(hexcolor, "[^0-9a-zA-Z]+", ""); 15 16 int r = Convert.ToByte(hexcolor.Substring(0, 2), 16); 17 int g = Convert.ToByte(hexcolor.Substring(2, 2), 16); 18 int b = Convert.ToByte(hexcolor.Substring(4, 2), 16); 19 int yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000; 20 21 if (yiq >= 128) 22 { 23 return "black"; 24 } 25 else 26 { 27 return "white"; 28 } 29 } 30 else 31 { 32 return "black"; 33 } 34 } 35 36 37 //Truncate text 38 public static string Truncate (string value, int count, bool strip=true) 39 { 40 if (strip == true){ 41 value = StripHtmlTagByCharArray(value); 42 } 43 44 if (value.Length > count) 45 { 46 value = value.Substring(0, count - 1) + "..."; 47 } 48 49 return value; 50 } 51 52 53 //Strip text from HTML 54 public static string StripHtmlTagByCharArray(string htmlString) 55 { 56 char[] array = new char[htmlString.Length]; 57 int arrayIndex = 0; 58 bool inside = false; 59 60 for (int i = 0; i < htmlString.Length; i++) 61 { 62 char let = htmlString[i]; 63 if (let == '<') 64 { 65 inside = true; 66 continue; 67 } 68 if (let == '>') 69 { 70 inside = false; 71 continue; 72 } 73 if (!inside) 74 { 75 array[arrayIndex] = let; 76 arrayIndex++; 77 } 78 } 79 return new string(array, 0, arrayIndex); 80 } 81 82 //Make the correct count of columns 83 public static string ColumnMaker(int Col, string ScreenSize) 84 { 85 string Columns = ""; 86 87 switch (Col) 88 { 89 case 1: 90 Columns = "col-"+ScreenSize+"-12"; 91 break; 92 93 case 2: 94 Columns = "col-"+ScreenSize+"-6"; 95 break; 96 97 case 3: 98 Columns = "col-"+ScreenSize+"-4"; 99 break; 100 101 case 4: 102 Columns = "col-"+ScreenSize+"-3"; 103 break; 104 105 default: 106 Columns = "col-"+ScreenSize+"-3"; 107 break; 108 } 109 110 return Columns; 111 } 112 113 114 private string Custom(string firstoption, string secondoption) 115 { 116 if (firstoption == "custom") 117 { 118 return secondoption; 119 } 120 else 121 { 122 return firstoption; 123 } 124 } 125 } 126 } 127 128 129 @helper DivBreakout() 130 { 131 string rawstring = ""; 132 133 <!-- Fluid settings --> 134 if (GetBoolean("Item.Fluid")) 135 { 136 rawstring = "</div></div></div></div>"; 137 <text>@rawstring</text> 138 139 if (GetBoolean("ParagraphContainerIsLast")) 140 { 141 <!-- Makes the banner stick to the bottom --> 142 rawstring = "<div class=\"container-fluid\" style=\"position: relative !important; margin-bottom: -30px; \"><div class=\"row\">"; 143 } 144 else if (GetBoolean("ParagraphContainerIsFirst")) 145 { 146 <!-- Makes the banner stick to the top --> 147 if (Pageview.Area.Item["HeaderLayoutMode"].ToString() != "solid") 148 { 149 rawstring = "<div class=\"container-fluid\" style=\"position: relative !important; top: -30px; \"><div class=\"row\">"; 150 } 151 else 152 { 153 rawstring = "<div class=\"container-fluid\" style=\"position: relative !important; top: -31px; \"><div class=\"row\">"; 154 } 155 } 156 else 157 { 158 rawstring = "<div class=\"container-fluid\"><div class=\"row\">"; 159 } 160 <text>@rawstring</text> 161 } else { 162 var layoutwidth = GetString("Item.LayoutWidth"); 163 rawstring = "<div class=\"col-md-" + @layoutwidth + " col-xs-" + @layoutwidth + "\">"; 164 <text>@rawstring</text> 165 } 166 } 167 168 @helper DivBreakbackin() 169 { 170 string rawstring = ""; 171 172 if (!GetBoolean("Item.Fluid")) 173 { 174 rawstring = "</div>"; 175 <text>@rawstring</text> 176 } 177 else 178 { 179 rawstring = "</div></div>"; 180 <text>@rawstring</text> 181 182 <!-- Makes the rest of the page work proberly --> 183 if (!GetBoolean("ParagraphContainerIsLast")) 184 { 185 rawstring = "<div class=\"container\"><div class=\"row\"><div class=\"col-md-12 col-sm-12 col-xs-12\"><div class=\"row\" id=\"maincontent\" title=\"Content area\">"; 186 <text>@rawstring</text> 187 } 188 } 189 } 190 @{ 191 init(); 192 } 193 194 @functions { 195 private int columnsWritten { get; set; } 196 private int columns { get; set; } 197 198 public void init() 199 { 200 columnsWritten = Dynamicweb.Input.FormatInteger(System.Web.HttpContext.Current.Items["currentColumns"]); 201 columns = GetInteger("Item.Width"); 202 System.Web.HttpContext.Current.Items["currentColumns"] = columnsWritten + GetInteger("Item.Width"); 203 } 204 205 public void Fluid() 206 { 207 columnsWritten = Dynamicweb.Input.FormatInteger(System.Web.HttpContext.Current.Items["currentColumns"]); 208 columns = 12; 209 System.Web.HttpContext.Current.Items["currentColumns"] = columnsWritten + 12; 210 } 211 212 public string ColumnClass() 213 { 214 if (GetString("Item.WidthMobile") == "hide"){ 215 return "col-md-" + GetString("Item.Width") + " hidden-xs"; 216 } else { 217 return "col-md-" + GetString("Item.Width") + " col-xs-" + GetString("Item.WidthMobile"); 218 } 219 } 220 221 public string NewRow() 222 { 223 if (columns + columnsWritten > 12) 224 { 225 System.Web.HttpContext.Current.Items["currentColumns"] = columns; 226 return "</div><div class=\"row\">"; 227 } 228 else 229 { 230 return string.Empty; 231 } 232 233 } 234 } 235 236 @{ 237 string rawstring = ""; 238 string image = ""; 239 240 if (GetString("Item.Background.Image.Image") == "custom") 241 { 242 image = GetString("Item.Background.Image.CustomImage"); 243 } 244 else if (GetString("Item.Background.Image.Image") == "no-image") 245 { 246 image = ""; 247 } 248 else 249 { 250 image = "/Templates/Designs/Dwsimple/images/background/" + GetString("Item.Background.Image.Image"); 251 } 252 253 <!-- FONT SETTINGS --> 254 string TitleFont = CustomFont(GetString("Item.TitleFont.Font"), GetString("Item.TitleFont.CustomFont")); 255 string TitleSize = GetString("Item.TitleFont.Size") + "px"; 256 string TitleColor = GetString("Item.TitleFont.Color.Color"); 257 string TitleLineHeight = CheckExistence(GetString("Item.TitleFont.LineHeight"), "1"); 258 string TitleSpacing = CheckExistence(GetString("Item.TitleFont.LetterSpacing"), "0"); 259 string TitleCasing = GetString("Item.TitleFont.Casing"); 260 string TitleWeight = CheckExistence(GetString("Item.TitleFont.Weight"), "300"); 261 262 string SubFont = CustomFont(GetString("Item.SubtitleFont.Font"), GetString("Item.TitleFont.CustomFont")); 263 string SubSize = GetString("Item.SubtitleFont.Size") + "px"; 264 string SubColor = GetString("Item.SubtitleFont.Color.Color"); 265 string SubLineHeight = CheckExistence(GetString("Item.SubtitleFont.LineHeight"), "1"); 266 string SubtitleSpacing = CheckExistence(GetString("Item.SubtitleFont.LetterSpacing"), "0"); 267 string SubCasing = GetString("Item.SubtitleFont.Casing"); 268 string SubtitleWeight = CheckExistence(GetString("Item.SubtitleFont.Weight"), "300"); 269 270 string textpos = "0px"; 271 272 if (GetString("Item.Mode") == "shadow") { 273 <style> 274 .dw-carousel-caption { 275 text-shadow: 0px 0px 8px #333; 276 } 277 </style> 278 } 279 280 if (GetString("Item.Mode") == "boxed") { 281 <style> 282 .dw-carousel-caption { 283 background-color: @GetString("Item.CaptionBackgroundColor.Color"); 284 } 285 </style> 286 } 287 288 <!-- COLUMNS + FLUID CONTROLS--> 289 string column = ""; 290 291 if (!GetBoolean("Item.Fluid")){ 292 NewRow(); 293 294 column = ColumnClass(); 295 } 296 else 297 { 298 Fluid(); 299 } 300 301 302 string TextClass = ""; 303 304 if (GetString("Item.Position") == "left"){ 305 TextClass = "container"; 306 } 307 308 if (GetString("Item.Position") == "center"){ 309 TextClass = "text-center"; 310 } 311 312 if (GetString("Item.Position") == "right"){ 313 TextClass = "container text-right"; 314 } 315 316 if (!GetBoolean("Item.Fluid")){ 317 TextClass += " extra-padding"; 318 } 319 } 320 321 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=@TitleFont:100,200,300,400,500,600,700,800,900" /> 322 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=@SubFont:100,200,300,400,500,600,700,800,900" /> 323 324 <!-- Fluid settings --> 325 @DivBreakout() 326 327 <div class="@column"> 328 @if (!string.IsNullOrWhiteSpace(@image)){ 329 rawstring = "<section style="\" height:"="" "="" +="" @getstring("item.height")="" +="" "px="" !important;="" background:="" url('/admin/public/getimage.ashx?width="1920&compression=75&Crop=5&image=" "="" +="" @image="" +="" "')="" no-repeat="" 0="" 0;="" background-position:="" center;="" margin-bottom:="" 30px\"="">"; 330 <text>@rawstring</text> 331 } else { 332 rawstring = "<section style="\" background-color:"="" "="" +="" @getstring("item.background.color.color")="" +="" ";="" height:="" "="" +="" @getstring("item.height")="" +="" "px="" !important;="" margin-bottom:="" 30px="" \"="">"; 333 <text>@rawstring</text> 334 } 335 336 @{ 337 textpos = ((GetInteger("Item.Height")/2)-(GetInteger("Item.TitleFont.Size") + GetInteger("Item.SubtitleFont.Size"))).ToString() + "px"; 338 } 339 340 <div class="@TextClass"> 341 <div style="padding-top: @textpos"> 342 <div><span class="title dw-carousel-caption" style="font-family: @TitleFont; font-size: @TitleSize; color: @TitleColor; line-height: @TitleLineHeight; text-transform: @TitleCasing; font-weight: @TitleWeight; letter-spacing: @TitleSpacing;">&nbsp;@GetString("Item.Title")&nbsp;</span></div> 343 @if (!string.IsNullOrWhiteSpace(@GetString("Item.Subtitle"))){ 344 <div> 345 <span class="subtitle dw-carousel-caption" style="font-family: @SubFont; font-size: @SubSize; color: @SubColor; line-height: @SubLineHeight; text-transform: @SubCasing; font-weight: @SubtitleWeight; letter-spacing: @SubtitleSpacing">&nbsp;&nbsp;&nbsp;@GetString("Item.Subtitle")&nbsp;&nbsp;&nbsp;</span> 346 </div> 347 } 348 <span class="clearfix"></span> 349 350 @if (!string.IsNullOrWhiteSpace(GetString("Item.Link"))){ 351 string link = @GetString("Item.Link"); 352 353 <a href="@link" class="btn btn-dw-primary">@GetString("Item.LinkText")</a> 354 } 355 </div> 356 </div> 357 </section></section></div> 358 359 <!-- Fluid settings --> 360 @DivBreakbackin() 361 362 @functions{ 363 private string CustomFont (string firstfont, string secondfont) 364 { 365 if (firstfont == "custom") 366 { 367 return secondfont; 368 } 369 else 370 { 371 return firstfont; 372 } 373 } 374 375 private string CheckExistence (string stringitem, string defaultvalue) 376 { 377 if (!string.IsNullOrWhiteSpace(stringitem)) { 378 return stringitem; 379 } else { 380 return defaultvalue; 381 } 382 } 383 }