Category Archives: Stockholm Pride

Creating Page Type Classes from Page Types in EPiServer CMS 7

After my upgrade of Stockholm Pride to EPiServer 7 CMS (blog post coming soon) I wanted the project to be a bit more shiny with some Code Managed Page Types.

I forked Erik Nordin’s utility to create classes for PageTypeBuilder in an existing project. Did some research on what attributes I needed to create a similar thing with EPiServer 7 CMS.

As a bonus I also gave it a little more EPiServer look-and-feel:

create pt

Since I don’t know if I should commit this back to Erik Nordin’s GitHub or not, you can download it from GitHub.

Current status

I would see this as a first draft of the creation tool that worked quite good for my upgrade of Stockholm Pride.

It creates Properties for the most common properties in EPiServer but gives a template where you can decide if you want to go with a BackingTypeAttribute or using EditorDescriptors/UIHints instead (see below).

Attributes and value types

I’ve tried to cover all correct DataTypes Attributes such as replacing PropertyImageUrl with Url and setting UIHints but I still thinks it needs some more cleaning.

Note that since I only check for what’s in the database, avoid running this tool while already having Page Types Classes in your project.

Custom Properties

For now, the support for Custom Properties are not that great. I try to read out what kind of Data Value the Properties are meant to return but leave a code comment to those Properties I don’t know what to do with.

This way you can make a search for //DefinitionType= and decide for yourself if you want to use the UIHintAttribute or the BackingFieldAttribute to solve this problem.

Some of the older EPiServer Properties are obsolete which mean that they should not be used as a BackingField.

UILanguageProperty is one of them which luckily is only a property that returns a string, but the Editor may select among all activated Languages.

By reflection I can find out exactly how that list is populated.

Example of EditorDescriptor

This means that UILanguageProperty can easily be replaced with an EditorDescriptor that gives the same functionality:

//[BackingType(typeof(PropertyUILanguage))] -- PropertyUILanguage has been obsoleted and will be removed in a future release.
[Display(Name = "Content Language")]
public virtual string ContentLanguage { get; set; }

[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "UILanguage")]
public class UILanguageEditorDescriptor : EditorDescriptor
   public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
      SelectionFactoryType = typeof(UILanguageSelectionFactory);
      ClientEditingClass = "epi.cms.contentediting.editors.SelectionEditor";

      base.ModifyMetadata(metadata, attributes);

public class UILanguageSelectionFactory : ISelectionFactory
   public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
      var languages = new List<SelectItem>();
      foreach (System.Globalization.CultureInfo info in LocalizationService.Current.AvailableLocalizations)
         string nativeName = info.NativeName;
         if (info.TextInfo.ANSICodePage != 0x4e4)
            nativeName = nativeName + string.Format(" ({0})", info.EnglishName);
         languages.Add(new SelectItem { Value = info.Name, Text = nativeName });
      return languages;

NullReferenceException from TinyMCESettings, InputTinyOptions.GetActiveToolsHTML() and ToolbarRow in EPiServer 7

I’m upgrading a quite old EPiServer CMS website that has been alive since about 2007 from EPiServer CMS 6 to EPiServer 7 CMS.

Among the first things after using EPiServer Deployment Center to upgrade from CMS 6 R2 to 7 CMS is that I can’t use the new shiny Editor Mode.

Not being able to edit First Page

It looks good but no reaction when I click to edit a property or trying to enter Forms Editing.

A quick look in my browser’s Developer Network  gives me a HTTP Error 500 from the following url:


I also had some strange errors when trying to edit TinyMCE Property Settings:

edit xhtmlstring settings

After some Reflecting, Debugging and some hints from I found that in the upgrade from 6R2 to 7, the Upgrade Tool moves some DDS-items such as Property Configuration from tblBigTable to tblSystemBigTable.

But the View VW_EPiServer.Editor.TinyMCE.ToolbarRow nor the Stored Procedure Save_EPiServer.Editor.TinyMCE.ToolbarRow are not updated to load or save from the correct Big Table causing the DDS to be able to find the TinyMCESettings correctly but when the nested entities ToolbarRow are loaded, no such data is found. Hence TinyMCESettings.Toolbar returns a list but all items in the list are NULL.

The correct procedure seems to be to change the design of the View to

SELECT CAST(R01.pkId AS varchar(50)) + ':' + UPPER(CAST([Identity].Guid AS varchar(50))) AS Id, R01.pkId AS StoreId, [Identity].Guid AS ExternalId, R01.ItemType
FROM dbo.tblSystemBigTable AS R01 INNER JOIN
 dbo.tblBigTableIdentity AS [Identity] ON R01.pkId = [Identity].pkId
WHERE (R01.StoreName = 'EPiServer.Editor.TinyMCE.ToolbarRow') AND (R01.Row = 1)

and the Stored Procedure to

USE [dbStockholmPrideDev_EPi7]
/****** Object: StoredProcedure [dbo].[Save_EPiServer.Editor.TinyMCE.ToolbarRow] Script Date: 03/04/2013 09:45:36 ******/
ALTER procedure [dbo].[Save_EPiServer.Editor.TinyMCE.ToolbarRow]
@Id bigint output,
@UniqueId uniqueidentifier,
@ItemType nvarchar(2048)
declare @pkId bigint
 select @pkId = pkId from tblBigTableIdentity where [Guid] = @UniqueId
 if @pkId IS NULL
 begin transaction
 insert into [tblBigTableIdentity]([Guid], [StoreName]) values(@UniqueId, 'EPiServer.Editor.TinyMCE.ToolbarRow')
select @Id = SCOPE_IDENTITY()
 insert into [tblSystemBigTable] (pkId, StoreName, Row, ItemType)
 values(@Id, 'EPiServer.Editor.TinyMCE.ToolbarRow', 1, @ItemType )
commit transaction
 begin transaction
 select @Id = @pkId
 DECLARE @rows int
 select @rows = count(*) from [tblSystemBigTable] where pkId = @Id
 if(@rows < 1) begin
 insert into [tblSystemBigTable] (pkId, StoreName, Row, ItemType)
 values(@Id, 'EPiServer.Editor.TinyMCE.ToolbarRow', 1, @ItemType )
 commit transaction