public partial class Page1 :System.Web.UI.Page
{
public static LGDP.LDGPSession var1 = null;
private void Login(this, EventArgs e)
{
var1 = new LGDPSession(this, data, data);
}
public bool IsLoggedIn()
{
bool login = false;
if (var1 != null)
{
login = true;
}
return var1;
}
}
How do I access the Page1 static var1 or function IsLoggedIn() from Page2.apsx ?
public partial class Page2 :System.Web.UI.Page
{
Page1.(nothing shows up here)
}
ANSWER —– created separate class and accessed public var in pageload / postback
private static bool _login = false;
public static void SetLoggedIn(object lgdps)
{
if (lgdps == null)
{
_login = false;
}
if (lgdps != null)
{
_login = true;
}
}
public static bool IsLogin
{
get { return _login; }
}
It’s better to create a base class with your functions in it:
And then you can access
IsLoggedInfrom you pages when you inherit fromBasePage