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.
Call class from Web User Control vb.net
-
05-08-2022 - |
Pregunta
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?
Solución 2
Otros consejos
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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow