Error compiling template "Designs/Dwsimple/ItemPublisher/List/NewsList.cshtml"
Line 159: 'Dynamicweb.Base' does not contain a definition for 'StripHTML'

1 @using System.Text.RegularExpressions 2 @using System.Web 3 4 5 @functions{ 6 public class WrapMethods 7 { 8 //Gets the contrasting color 9 public static string getContrastYIQ(string hexcolor) 10 { 11 if (hexcolor != "") 12 { 13 hexcolor = Regex.Replace(hexcolor, "[^0-9a-zA-Z]+", ""); 14 15 int r = Convert.ToByte(hexcolor.Substring(0, 2), 16); 16 int g = Convert.ToByte(hexcolor.Substring(2, 2), 16); 17 int b = Convert.ToByte(hexcolor.Substring(4, 2), 16); 18 int yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000; 19 20 if (yiq >= 128) 21 { 22 return "black"; 23 } 24 else 25 { 26 return "white"; 27 } 28 } 29 else 30 { 31 return "black"; 32 } 33 } 34 35 36 //Truncate text 37 public static string Truncate (string value, int count, bool strip=true) 38 { 39 if (strip == true){ 40 value = StripHtmlTagByCharArray(value); 41 } 42 43 if (value.Length > count) 44 { 45 value = value.Substring(0, count - 1) + "..."; 46 } 47 48 return value; 49 } 50 51 52 //Strip text from HTML 53 public static string StripHtmlTagByCharArray(string htmlString) 54 { 55 char[] array = new char[htmlString.Length]; 56 int arrayIndex = 0; 57 bool inside = false; 58 59 for (int i = 0; i < htmlString.Length; i++) 60 { 61 char let = htmlString[i]; 62 if (let == '<') 63 { 64 inside = true; 65 continue; 66 } 67 if (let == '>') 68 { 69 inside = false; 70 continue; 71 } 72 if (!inside) 73 { 74 array[arrayIndex] = let; 75 arrayIndex++; 76 } 77 } 78 return new string(array, 0, arrayIndex); 79 } 80 81 //Make the correct count of columns 82 public static string ColumnMaker(int Col, string ScreenSize) 83 { 84 string Columns = ""; 85 86 switch (Col) 87 { 88 case 1: 89 Columns = "col-"+ScreenSize+"-12"; 90 break; 91 92 case 2: 93 Columns = "col-"+ScreenSize+"-6"; 94 break; 95 96 case 3: 97 Columns = "col-"+ScreenSize+"-4"; 98 break; 99 100 case 4: 101 Columns = "col-"+ScreenSize+"-3"; 102 break; 103 104 default: 105 Columns = "col-"+ScreenSize+"-3"; 106 break; 107 } 108 109 return Columns; 110 } 111 112 113 private string Custom(string firstoption, string secondoption) 114 { 115 if (firstoption == "custom") 116 { 117 return secondoption; 118 } 119 else 120 { 121 return firstoption; 122 } 123 } 124 } 125 } 126 127 128 @helper GetNewsList(dynamic Loop, int Length=120) 129 { 130 foreach (LoopItem newsitem in Loop){ 131 string Image = newsitem.GetString("ItemPublisher:Item.GeneralImage"); 132 string Url = newsitem.GetString("ItemPublisher:Item.Url"); 133 string Title = newsitem.GetString("ItemPublisher:Item.Heading"); 134 string Author = newsitem.GetString("ItemPublisher:Item.GeneralAuthor"); 135 string Date = newsitem.GetString("ItemPublisher:Item.Date"); 136 string Description = newsitem.GetString("ItemPublisher:Item.Text"); 137 Description = System.Web.HttpContext.Current.Server.HtmlDecode(Dynamicweb.Base.StripHTML(Description)); 138 139 <li class=""> 140 <div class="listing-image"> 141 <a href="@Url"> 142 <img src="/Admin/Public/GetImage.ashx?image=@Image&amp;width=300&amp;height=180&amp;compression=75" class="content-image img-responsive" alt="" /> 143 </a> 144 </div> 145 <div class="listing-body"> 146 <h3><a href="@Url">@Title</a></h3> 147 <span class="list-item-info"> @Date 148 </span> 149 <p> 150 @WrapMethods.Truncate(Description, Length) 151 </p> 152 <p> 153 <a href="@Url" class="pull-right btn btn btn-sm btn-dw-secondary">@Translate("Read more", "Read more")</a>&nbsp; 154 </p> 155 </div> 156 </li> 157 } 158 } 159 160 161 <div class="row"> 162 <div class="col-md-12 col-sm-12 col-xs-12"> 163 <h3 class="dw-section-title"><span>@GetGlobalValue("Global:Page.Name")</span></h3> 164 </div> 165 </div> 166 <section class="slice"> 167 <ul class="list-listings blog-list"> 168 @GetNewsList(GetLoop("ItemPublisher:Items.List"), 260) 169 </ul> 170 </section>