views:

387

answers:

3

I'm getting an error in .net when trying to declare a Public class on my code behind 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'm getting is BC30508: 'someClass' cannot expose type 'className' in namespace '<Default>' through class '_Default'.

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

I'm not sure if I'm trying the right methods (I've tried several ways of declaring the public class) or if it can even be done... Thanks for taking a look at it.

-Birk

A: 

Check the protection level of the _Default class. It might not be setup as a partial class and that will result in your protection level issue that you are seeing.

Al Katawazi
His posted sample includes "Partial"
Joel Coehoorn
+3  A: 

Check the protection level of your className type. Did you forget to mark it public?

That error message means you have something that is has restricted access, and you are trying to use it in a way that would allow access outside the restrictions. For example, if your className type is internal or a private child class of _Default, but you add a public member of that type as a property your assembly would expose a type as part of it's interface that is otherwise unusable.

Joel Coehoorn
Doh... you're right! Thanks Everyone.
Birk
+1  A: 

It's almost certainly the declaration of your "className" class. Try setting it to public.

Lance Harper