bartek.tatkowski@nansen.se
Mar 23, 2010
  3418
(0 votes)

How to get the PageTypeName property without creating a page instance

In a project we’re currently working on here at Nansen we stumbled upon the need to get the name of a page type without having an actual reference to page of that type.

Since we’re using Joel’s PageTypeBuilder, getting the name was a simple task of reflecting the PageTypeAttributes object.

public static string GetPageTypeName<T>() where T : TypedPageData
{
    System.Reflection.MemberInfo memberInfo = typeof(T);
    object[] attributes =  memberInfo.GetCustomAttributes(typeof(PageTypeAttribute), false); 
    if (attributes.Count() > 0)
    {
        PageTypeAttribute pta = attributes.First() as PageTypeAttribute;
        return pta.Name;
    } 
    return string.Empty;
}
Mar 23, 2010

Comments

Please login to comment.
Latest blogs
Optimizely CMS 13 (Pre-release) Visual Builder

This post captures a proof of concept built on an Alloy MVC site upgraded to Optimizely CMS 13 pre-release, focused on Visual Builder, how to model...

Francisco Quintanilla | Feb 11, 2026 |

Personalized User Journeys with Optimizely CMS

Daniel Copping | Feb 10, 2026 |

Optimizely CMS 12 behaving strangely after upgrading from CMS 11

After upgrading from Optimizely CMS 11 to CMS 12, content type changes stopped working due to an assembly version mismatch. This post explains the...

Henning Sjørbotten | Feb 10, 2026 |

Episode 2 of the OMVP Strategy Roundtable is out

AI is everywhere right now. Strategy decks are full of it. Roadmaps promise it. Tools are shipping faster than teams can keep up. But when it comes...

Satata Satez | Feb 10, 2026

Beware when storing complex types in PropertyList!

If you store complex types in a PropertyList property in Optimizely, you might want to consider how they perform. Read here for a performance tip.

Stefan Holm Olsen | Feb 9, 2026 |

AI Assistant Chat for Optimizely

The Epicweb AI-Assistant integrates AI Assistant Chat directly into Optimizely CMS 12 and 13, assisting editors in analyzing, managing, translating...

Luc Gosso (MVP) | Feb 8, 2026 |