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[] _smallNumbers = new string[] { "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" };
<a href="http://www.fruitbatscode.com/net/c/uad-9-numbers-to-words#more-454" class="more-link">Read more...</a>
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 you would a normal dictionary. When you instantiate a copy it picks up the current query string. There are two ToString() methods, one just return the query string and the other appends another string to the end and takes care of the ? & issues.
Read more…
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 context, string path)
{
if (context != null && !String.IsNullOrEmpty(path))
{
return "/" + path.Replace(context.Server.MapPath("/"), "").Replace(@"\", "/");
}
else return null;
}
<a href="http://www.fruitbatscode.com/net/c/uad6-physical-path-to-virtual#more-433" class="more-link">Read more...</a>
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 handles all the page, content and control creation with a single base class that you can implement to create page renderers for any page type. Current renderers are the LiveEdit renderer, Content Block, File Include and Rss (Mobile next).
Read more…
Whilst working on the CMS I needed to be able to pass back the html a control will render when the user first adds it. The control doesn’t exist on the page yet as the sections are added via javascript. It was very easy to pass in StringWriter to the render function to get the html
Read more…