Blog posts


  • CSS3 boxshadow with opacity snippet

    November 10, 2010 | Tags: CSS, Snippet
    Here's how to create a style with boxshadow for different browsers (-webkit = Safari, -moz = Firefox etc). It also shows how to use opacity using the rgba-constructor:
    rgba(red, green, blue, opacity ranging from 0.0 to 1.0)

    The boxshadow attributes are:
    distance x, distance y, blur, shadow color

    <style type="text/css">
    .shadow {
    box-shadow:5px 5px 20px rgba(0, 0, 0, 0.75);
    -webkit-box-shadow:5px 5px 20px rgba(0, 0, 0, 0.75);
    -moz-box-shadow: 5px 5px 20px rgba(0, 0, 0, 0.75);
    }
    </style>
    This is a sample of the shadow above

  • Prevent EPiServer UrlRewrite

    November 09, 2010 | Tags: EPiServer, ASP.NET, SEO, Troubleshooting
    Sometimes it's needed to turn off EPiServers function for Url rewrite, like if you for instance writes a link-element with a canonical url (which helps search engine optimization (SEO)). The UrlRewriteProvider works as a HTTP-module, which means that it's running after your page is rendered, parsing all your Urls in a predefined list of elements and attributes.

    To prevent EPiServer's Url rewrite to occur do the following to your element:
    1) Add an id-attribute to your element
    2) Add a special EPiServer attribute to prevent the rewrite


    Original code:
    <link rel="canonical" href="the/url/not/to/rewrite" />

    Updated code:
    <link rel="canonical" id="canonical1" <%=EPiServer.Web.UrlRewriteProvider.UrlPreventRewriteAttribute %>="true" href="the/url/not/to/rewrite" />

  • Get all values from CheckBoxList in C#

    November 04, 2010 | Tags: C#, LINQ, Snippet
    This is a class that add an extension to the CheckBoxList class to return a comma separated string with all the selected values.

    You call this function by the following:
    string mySelectedValues = myCheckBoxList.GetSelectedValues();
    The class to place somewhere in you project (remember to add a using-reference to any class you want to call this function from:
    public static class CheckBoxListExtension {
    public static string GetSelectedValues(this CheckBoxList checkBoxList) {
    string retval = string.Empty;

    try {
    foreach (ListItem item in checkBoxList.Items) {
    if (item.Selected) {
    retval += item.Value + ',';
    }
    }
    retval.TrimEnd(',');
    }
    catch (Exception) {
    }

    return retval;
    }
    }

    Or the same code if LINQ is your poison:
    public static class CheckBoxListExtension {
    public static string GetSelectedValues(this CheckBoxList checkBoxList) {
    string retval = string.Empty;

    try {
    retval = checkBoxList.Items.Cast<ListItem>().Where(item => item.Selected).Aggregate(retval, (current, item) => current + (item.Value + ','));
    retval.TrimEnd(',');
    }
    catch (Exception) {
    }

    return retval;
    }
    }

  • EPiServer: Get unpublished children too

    October 29, 2010 | Tags: EPiServer, C#, Snippet
    DataFactory.Instance.GetChildren(myPageLink) only returns the children which are published. If you also want to get the pages that aren't yet published you should use the LanguageSelector-parameter which utilizes language fallback to return all children published or not. It doesn't matter if your EPiServer site is in one language only, the following will return published and unpublished children:
    PageDataCollection children = DataFactory.Instance.GetChildren(myPageLink, LanguageSelector.AutoDetect(true));

  • Microsoft Dynamics CRM Framework for EPiServer available for download

    October 27, 2010 | Tags: EPiServer, Microsoft CRM, Open source
    A Microsoft Dynamics CRM Framework for EPiServer has been released as open source by Karoline Klever and is available for download at http://crmframework.codeplex.com/

    You'll also find the documentation at Codeplex.