Search code examples
asp.netvb.netmoduleinline-code

How do I access a module or a public class with public shared members from inline vb code <% .. %>


I can access a module from code behind but not from the aspx page in inline VB code <% ... %>.

I know its got to be something simple but I can't seem to find the answer anywhere.


Solution

  • If you want to run a static method from your aspx you can do something like this:

    <% MyNamespace.MyClass.MyMethod() %>

    If you want to instancate an object and call a method on that you can do that as well:

    <%
        Dim obj As MyNamespace.MyClass
        obj = New MyNamespace.MyClass()
        obj.MyMethod()
    %>