0

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));
EvilSyn
  • 2,412
  • 7
  • 24
  • 22

1 Answers1

1

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

TheSoftwareJedi
  • 34,421
  • 21
  • 109
  • 151
  • OMG. I can't believe it. You'd think that namespace would be in scope (I have it at the same namespace level as the page itself). OY. Thank you. – EvilSyn Oct 18 '08 at 17:31
  • @EvilSyn Get R# and this won't happen again. :) http://www.jetbrains.com/resharper/ – bzlm Sep 30 '10 at 12:03