Retrieving objects between classes

curtissea

New Member
I always get tied up with small things like this... I need to access an objects properties created in class 'Login' from my welcome page class 'Default'. When I try to reference the class so that I may access the object, VS 2010 doesn't list it as available like it normally would, and forcing the request just returns an error.My \[code\]Login\[/code\] Class is defined like so:\[code\]public abstract class Login : System.Web.UI.UserControl{ ... private void Login_click(object sender, EventArgs e) { MyObject myObject = new MyObject(); myObject.property1 = "something"; }}\[/code\]And then i wish to access \[code\]myObject\[/code\] from my default class, like this:\[code\]public class Default : System.Web.UI.Page{ ... private void Page_load(object sender, System.EventArgs e) { string someLocalVar = Login.myObject.property1; }}\[/code\]Where \[code\]property1\[/code\] is a property set in the Login class. This does not work, however, and VS doesn't even recognize the Login class; instead it treats it as a reserved word of some sort. These two files are in the same project, so that shouldn't be an issue in the \[code\]using\[/code\] section. I've accessed variables in this manner between other classes before, just not this time for some reason.Thanks!
 
Back
Top