Using a class as a public variable in asp.net

I get an error in .net when I try to declare an open class in my code after page.

Partial Class _Default
    Inherits System.Web.UI.Page

    Public someVariable as integer
    Public someClass as className

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load [...]

The error I get is this BC30508: 'someClass' cannot expose type 'className' in namespace '<Default>' through class '_Default'.

The goal here is to access class properties in script blocks on an aspx page like this <%=someClass.classProperty%>

I'm not sure that I am trying to use the correct methods (I tried several ways to declare a public class), or if you can even do this ... Thanks for looking at it.

+3
source share
3 answers

Check the level of protection of your type className. Did you forget to mention this in public?

, , , , . , className - internal private _Default, , , .

+8

className. .

+1

_Default. , , , .

0

Source: https://habr.com/ru/post/1706326/


All Articles