Reputation: 1149
How can I get the Page Type for the current page. I tried
CurrentPage.GetType();
but no success. I need to check if the Page Type equals a specific type in order to do something or not.
Thanks
Upvotes: 2
Views: 9111
Reputation: 949
With a page type builder strongly typed class you can use the C# is keyword
e.g
if (CurrentPage is SomeStronglyTypeClass)
Upvotes: 5
Reputation: 7391
If you're using Page Type Builder you can also use the PageTypeResolver class.
Upvotes: 2
Reputation: 17156
You need to check the PageTypeName
or PageTypeID
properties, like this:
if(CurrentPage.PageTypeName == "StartPage")
// Do something
Check the reference: http://sdk.episerver.com/library/cms5/html/AllMembers_T_EPiServer_Core_PageData.htm
The GetType()
method is declared on System.Object
and returns the System.Type
for the object. Is is available on all types in the .NET Framework since all types inherit from System.Object
.
Upvotes: 8