Question

I got a class name DataAccess

i.e:

Public Class DataAccess
-- some functiom--
End class

I'm creating one Web User Control file name uc_Data

i can't call DataAccess class from web user control code behind

Protected Sub Page_Load(sender, ) Handles Me.Load
--want call the class here
End Sub

How to do it?

Was it helpful?

Solution 2

i found the solution by replace all the class in main project folder instead of put in App_Code folder. Then the class can be call from user control page.

OTHER TIPS

If you want to call a Shared function/sub-procedure in the DataAccess class, then do this:

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    ' Do not need to new up an instance, 
    ' just call method by name prefixed by class name
    DataAccess.DoSomething()
End Sub

If you want to call an instance function/sub-procedure in the DataAccess class, then do this:

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    ' Need to new up an instance of the class and then you can 
    ' call a method from that instance
    Dim theDataAccess As New DataAccess()
    theDataAccess.DoSomething2()
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top