Calling Class from another File ASP.NET VB.NET

Posted by davemackey on Stack Overflow See other posts from Stack Overflow or by davemackey
Published on 2010-04-22T13:55:29Z Indexed on 2010/04/22 14:03 UTC
Read the original article Hit count: 348

Filed under:
|

Lets say I have a class like this in class1.vb:

Public Class my_class
  Public Sub my_sub()
   Dim myvar as String
   myvar = 10
   Session("myvar") = myvar
  End Sub
End Class

Then I have a ASP.NET page with a code-behind file, default.aspx and default.aspx.vb and I want to call my_class. I'm doing the following, but it doesn't work:

Imports my_app.my_class
Partial Public Class _default
   Inherits System.Web.UI.Page
 Protected Sub Page_Load(ByVal sender as Object, ByVal e as System.EventArgs) Handles Me.Load
   my_class()
 End Sub
End Class

I get a "Reference to a non-shared member requires an object reference"

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about import