1

I set up my project as follows:

  1. Make empty ASP project
  2. Add index.aspx
  3. Add url mapping for index to Web.config

Great, it works. Now I want to call a function inside the aspx file, I go ahead and make the function

Class Class1
    Public Shared Function SayHi() As String
        Return "Hi"
    End Function
End Class

and go on to the aspx file and start writing

<% Class1.

but intellisense offers no autocomplete, in fact its as if the class doesn't even exist. How can I achieve this simple task?

user81993
  • 6,167
  • 6
  • 32
  • 64
  • 1
    where is `Class1`? `Index.aspx.vb` file? if so maybe your `Class1` is really a [`Friend`](https://msdn.microsoft.com/en-us/library/76453kax.aspx?f=255&MSPPError=-2147217396) `Index.Class1` class –  Sep 02 '15 at 09:29
  • 1
    http://stackoverflow.com/questions/3763612/default-visibility-for-c-sharp-classes-and-members-fields-methods-etc – Steve Sep 02 '15 at 09:30
  • You will need `<%= Class1.SayHi %>` (notice the =) to put that value in the page. However, that doesn't fix autocomplete. – Hans Kesting Sep 02 '15 at 09:51
  • @fra9001 its in Class1.vb file – user81993 Sep 02 '15 at 16:54

1 Answers1

2

The Class will need to be made public:

Public Class Class1
    Public Shared Function SayHi() As String
        Return "Hi"
    End Function
End Class

And you can use it like this, using the fully qualified name:

<div>
    <%= WebApplication1.Class1.SayHi()%>
</div>
laylarenee
  • 3,276
  • 7
  • 32
  • 40