Blog posts


  • Halo on Atari 2600

    October 05, 2010 | Tags: Off-topic
    Was gaming better in the good old days? When 8-bit ruled the world. Well, judge for yourself as this litte time machine demonstrate what Halo would have look like running on an Atari 2600 back in the days.

    Play Halo on Atari 2600 right in your web browser!

    And if you don't know what an Atari 2600 is, you'll have a chance to learn it here.

  • C#: Shorten text to a fixed length

    October 05, 2010 | Tags: C#, Snippet
    Here's a little snippet of code to help shorten text to fit inside a predefined length. It doesn't just cut a position X, it's try to find where the closest white space or stop character and instead cut there. However, if the character to cut at is found below half the length of the defined length it's ignored.

    Call by:
    string shortAndSweet = LimitCharacters(aReallyLongText, 100);

    Function:
    public string LimitCharacters(string text, int length) {
    // If text in shorter or equal to length, just return it
    if (text.Length <= length) {
    return text;
    }

    // Text is longer, so try to find out where to cut
    char[] delimiters = new char[] { ' ', '.', ',', ':', ';' };
    int index = text.LastIndexOfAny(delimiters, length - 3);

    if (index > (length / 2)) {
    return text.Substring(0, index) + "...";
    }
    else {
    return text.Substring(0, length - 3) + "...";
    }
    }
    Adjust the delimiters as you find aproperiate.

  • Get start page Url in EPiServer CMS 5 or later

    October 03, 2010 | Tags: EPiServer, Snippet
    PageData pagedata = Global.EPDataFactory.GetPage(new PageReference(EPiServer.Configuration.Settings.Instance.PageStartId));
    EPiServer.UrlBuilder url = new EPiServer.UrlBuilder(pagedata.LinkURL);
    EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, pagedata.PageLink, System.Text.UTF8Encoding.UTF8);

  • Accessibility: Skip links

    October 03, 2010 | Tags: Accessibility, Snippet
    This is a really easy thing to do and will help all the people that rely on screen readers to view your pages. Screen readers will list all the content on your page, from top to bottom, starting over at each page. By visually viewing the page, the eye can jump over elements it already recognize (such as menus etc) right to the content that the viewer is interested in. Often the main content. With a few lines of HTML and a style you can enable all those who use screen readers to do the same.

    This is done by creating "invicible" links at the top of the page pointing to areas of interest. The first thought for doing something invicible might be to set the display style to "none". However, that would result in that some screen readers ignore the block just because it isn't visible at all. The correct approach is to have it still visible but remove it way off the screen.

    In order to support keyboard shortcuts we'll also add access keys to our links.

    Be sure to put the invicible menu in front of all other content.

    In this sample there are two links. One that jumps down to the HTML element with the id set to "content" and one link to a different page.

    The HTML part:
    <ul class="skip">
    <li><a accesskey="S" href="#content">Jump to main content</a></li>
    <li><a accesskey="3" href="/MySitemap.html">View sitemap</a></li>
    </ul>
    The style:
    .skip {
    position:absolute;
    top:-999px;
    }

    Recommended access keys:
    S - Skip navigation
    1 - Home page
    2 - What’s new
    3 - Site map
    4 - Search
    5 - Frequently Asked Questions (FAQ)
    6 - Help
    7 - Complaints procedure
    8 - Terms and conditions
    9 - Feedback form
    0 - Access key details

  • EPiServer: Unknown server tag 'EPiServerUI:DynamicTable'

    October 01, 2010 | Tags: EPiServer, Troubleshooting
    If you get a Unknown server tag 'EPiServerUI:DynamicTable' error when trying to access your EPiServer administration pages the most possible source would be that your web.config has different UI-paths. Check your web.config so that they are consistent (like in the example below, they all point at /mysite/UI/something):
    <siteSettings ... uiUrl="~/mysite/UI/" ... />

    <add virtualPath="~/mysite/UI/" ... />

    <location path="mysite/ui">..</location>

    <location path="mysite/ui/admin">..</location>
    Most likely you'll find that some of the UI-paths points to "somewhere-else/ui/", just point it to the correct folder and hopefully your problem will be solved.