Try our conversational search powered by Generative AI!

Determine whether a certain category is set for a page



I want to check to see whether a certain category exists for a page. I have pagedata and from that i can access category, right?

But how do i loop through the categories for that page to see if anyone matches the category i look for?



I'm looking for a category called "fish" now i have page A and want to find out if page A has the category fish added to it.



May 03, 2011 13:00
Try this (page is a PageData object)
var category = Category.Find("fish");
if (category != null)
  bool isOfCat = page.Category.MemberOf(category.ID);
Edited, May 03, 2011 14:38



Thanks, worked perfectly!

If any one else should find this useful:
Just remember to add a reference to EpiServer.DataAbstraction namespace   :-)


May 03, 2011 16:18
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.