I created the following extension method for a ViewPage:
using System.Web.Mvc;
namespace G3Site {
public static class ViewPage_Extensions {
public static void Test(this ViewPage vp) {
vp.Writer.Write("this is a test");
}
}
}
I then put an import statement on my aspx page
<%@ Import Namespace="G3Site" %>
I can call the Test() method through this just fine:
<% this.Test(); %>
But when I try to call it without reference to this:
<% Test(); %>
I get a compiler error:
CS0103: The name 'Test' does not exist in the current context
Does anyone have any idea why this is happening and is there a way around it?