Virtual Happy Hour is canceled this month (March) due to Good Friday.
Try our conversational search powered by Generative AI!
AI OnAI Off
Virtual Happy Hour is canceled this month (March) due to Good Friday.
Hi Mathias!
You need to move your eztension method into a static class, something like this:
public static class NewsExtension
{
public static string GetTitle(this PageData pageData)
{
return pageData["Title"] as string
}
}
/johan
Yes I tried that but I got this weird error "Extension methods must be defined in a non-generic static classy"
But I solved it. It was because my code behind had the same method GetTitle as my extension class. That is apperently not allowed? :P
Thanks!
Hello!
Im new to EPiserver.
I´m trying to write a news template. I am following <a href="http://www.frederikvig.com/2009/07/episerver-web-controls-newslist">Fredrik Vigs guide on how to manage newslist templates</a>
The problem is that he is using some sort of extension class for some of his functions. I am trying to print out some page properties using this code in the newslist template: Container.CurrentPage.GetTitle();
For this to work I am trying to write an extension class file with the GetTitle method, but I cant get it to work..
using EPiServer.Core;
namespace Qwerty.Extensions.Classes
{
public partial class News : PageData
{
public static string GetTitle(this PageData pageData)
{
string text = pageData["Title"] as string;
return text;
}
}
}
I get this error in my newspage template: "Extension methods must be defined in a non-generic static class"
and the same error in my news extension class.
please help! :)