Question

So I have an IList of business entities that I loop through in a ListView into an unordered list. I created an extension method on this Entity in my presentation layer. In code behind, I can Response.Write the result of this extension method, but when I try to access it through the ListView I get an error. The method is called IsCurrent and returns a bool... Here is my code:

<li><%#((CB.CMSFramework.WebPage)Container.DataItem).IsCurrent(Guid.Empty) %></li>

The error I get is: 'CB.CMSFramework.WebPage' does not contain a definition for 'IsCurrent' and no extension method 'IsCurrent' accepting a first argument of type 'CB.CMSFramework.WebPage' could be found (are you missing a using directive or an assembly reference?)

However... I get no error when I do this type of code from code behind:

WebPage w = new WebPage();
Response.Write(w.IsCurrent(Guid.Empty));
Was it helpful?

Solution

Your page needs to @Import the namespace containing the extension method

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top