Skip to content

Instantly share code, notes, and snippets.

View fredrikhaglund's full-sized avatar

Fredrik Haglund fredrikhaglund

View GitHub Profile
@fredrikhaglund
fredrikhaglund / AccordionContentArea.cshtml
Created April 11, 2018 10:24
How to render an Episerver ContentArea as an Accordion (using Bootstrap 2.x)
@using EPiServer.Core
@using EPiServer.Editor
@using EPiServer.Web.Mvc.Html
@model EPiServer.Core.ContentArea
@* Note! Put this file in /Shared/DisplayTemplates/ to make it available as a template *@
@{
var idAccordion = Guid.NewGuid().ToString("N");
var first = true;
@fredrikhaglund
fredrikhaglund / Lab: Course Import Lab
Last active April 12, 2016 13:14
This lab shows how to add a system integration job in EPiServer that loads a list of data and create, update and delete pages programmatically.
This lab shows how to add a system integration job in EPiServer that loads a list of data and create, update and delete pages programmatically.
@fredrikhaglund
fredrikhaglund / Lab: Slide Show
Last active April 11, 2016 12:31
Lab: Slide Show block for Episerver CMS (using Bootstrap v2.0 like Alloy demo templates)
Intended for EPiServer Alloy MVC demo templates or lab instructions for Episerver Fundamentals Developer training.
@fredrikhaglund
fredrikhaglund / ExternalStuffController.cs
Created October 2, 2015 13:28
EPiServer Partial Route Demo
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer;
using EPiServer.Core;
using EPiServer.Framework.DataAnnotations;
using EPiServer.Web;
using EPiServer.Web.Mvc;
using EPiServer.Web.Routing;
using EPiServerSite9.Business;
@fredrikhaglund
fredrikhaglund / StartPageValidator.cs
Created April 1, 2015 08:52
EPiServer: Example of using IValidate
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.SpecializedProperties;
using EPiServer.Validation;
namespace EPiServerSite5.Models.Pages
@fredrikhaglund
fredrikhaglund / TestPage.cs
Created December 14, 2014 22:06
EPiServer Developer Fundamentals - Demo of different editors and UI Extensions
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using EPiServer;
using EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors.SelectionFactories;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
@fredrikhaglund
fredrikhaglund / Setup.cs
Created June 20, 2014 23:22
Check if a user is an admin and if not try to elevate the application by restarting itself. When using the verb "runas" User Account Control will popup a dialog and ask for permission to include administrative rights or to login as an administrator.
public static string ProcessFilename
{
get { return Process.GetCurrentProcess().MainModule.FileName; }
}
private static bool HasAdministrativeRight()
{
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
return windowsIdentity != null
&& new WindowsPrincipal(windowsIdentity).IsInRole(WindowsBuiltInRole.Administrator);
@fredrikhaglund
fredrikhaglund / ChromeLauncher.cs
Created June 20, 2014 23:13
Launch Chrome from C#
internal static class ChromeLauncher
{
private const string ChromeAppKey = @"\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe";
private static string ChromeAppFileName
{
get
{
return (string) (Registry.GetValue("HKEY_LOCAL_MACHINE" + ChromeAppKey, "", null) ??
Registry.GetValue("HKEY_CURRENT_USER" + ChromeAppKey, "", null));
@fredrikhaglund
fredrikhaglund / SetupSnippet.cs
Last active August 29, 2015 14:02
How to register a protocol handler in C#
internal static class ChromeLauncher
{
private const string ChromeAppKey = @"\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe";
private static string ChromeAppFileName
{
get
{
return (string) (Registry.GetValue("HKEY_LOCAL_MACHINE" + ChromeAppKey, "", null) ??
Registry.GetValue("HKEY_CURRENT_USER" + ChromeAppKey, "", null));
@fredrikhaglund
fredrikhaglund / ConsoleHelper.cs
Last active January 4, 2017 12:12
Require a Console from a non command line application (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Launcher
{
class ConsoleHelper
{