0

I have some code on an aspx page where I'm embedding tags such as this:

 <td><%= row.DateFrom.StandardFormat %></td>
 <td><%= row.DateTo.StandardFormat %></td>

I have included the namespace on the page like this:

 <%@ Import Namespace="Utilities" %>
 <%@ Import Namespace="Utilities.ExtensionMethods" %>

This is obviously pretty trivial, and I can work around it in this case, but it irks me that this doesn't work. I want to know why.

Danny Ellis Jr.
  • 1,674
  • 2
  • 23
  • 38
  • Try providing a FULL and CLEAR explanation of the problem. I think I know what you're saying but you're requiring us to make some assumptions. We shouldn't have to assume what you already know. – jmcilhinney May 10 '20 at 14:21
  • Have you read [this](https://stackoverflow.com/questions/2074268/can-i-use-extension-methods-inline-in-an-aspx-page), which was the first result when I searched for "aspx extension methods"? What exactly did you search for if you didn't find it? – jmcilhinney May 10 '20 at 14:24
  • Apologies. I didn't find that post but it does answer my question. FWIW, my search was similar to my question title. – Danny Ellis Jr. May 10 '20 at 14:29
  • What was the issue in the end? I believe that answer mentioned a couple of possibilities. – jmcilhinney May 10 '20 at 14:30
  • @jmcilhinney, well I was wrong. I closed the page, cleaned the solution and built it. It compiled, but it blew up when I ran it. I'm just going to work around it for now. – Danny Ellis Jr. May 10 '20 at 14:41
  • @jmcilhinney Adding Public to the Module definition did fix it. – Danny Ellis Jr. May 10 '20 at 14:45
  • The default access level for a module is `Friend` so that must mean that an ASPX page is effectively accessing the type from outside its assembly. That should also mean that you can't access classes declared without an explicit access level. Not sure that that is the case though. If not then there appears to be a bit of an inconsistency there. – jmcilhinney May 10 '20 at 14:50

0 Answers0