Here is a very simple asp.net .Closest() function like the jquery one. public static class ControlExtensions { public static Control Closest(this Control control, Type type ){ Control closest = null; Control parent = control.Parent; while(closest == null && parent != null){ if(parent.GetType().ToString() == type.ToString()){ return parent; } parent = parent.Parent; } return null; } }
Utility to take a number and convert it to the english text. Not mine this one but lost the original url! If it’s yours let me know 😀 public class NumberToWords { // Single-digit and small number names private string[]…Continue Reading →
Ever had controls that need to add to the Query String but not duplicate or erase what’s already there? This is a little utility I dug out and just changed to use a generic dictionary recently. Just use it as…Continue Reading →
Simple util to take a physical path and gets its virtual equivalent. public static string PhysicalPathToVirtual(string path) { if (HttpContext.Current != null && !String.IsNullOrEmpty(path)) { return "/" + path.Replace(HttpContext.Current.Server.MapPath("/"), "").Replace(@"\", "/"); } else return null; } public static string PhysicalPathToVirtual(HttpContext…Continue Reading →
I always seem to forget how to do this so I’m just leaving a note for myself 🙂 To convert to string: Jayrock.Json.Conversion.JsonConvert.ExportToString([object]); To convert back again ([object])Jayrock.Json.Conversion.JsonConvert.Import(typeof([object]), result);
It’s been a bit quite round here recently! Don’t be fooled! The CMS is more or less finished. Just refactoring and preparing bits and bobs. The actual core itself hasn’t really changed in 6 months and is independent from the CMS, it…Continue Reading →