R
Rich
The following code produced a singleton object with application scope
when it should have had page scope:
public class Singleton
{
private static Singleton uniqueInstance = null;
private Singleton()
{
}
public static Singleton getInstance()
{
if (uniqueInstance == null)
uniqueInstance = new Singleton();
return uniqueInstance;
}
}
public partial class Default1age
{
Singleton s = Singleton.getInstance();
void Page_Load(...)
{...}
void Button1Clicked(...)
{...}
}
public partial class Default2age
{
Singleton s = Singleton.getInstance(); // this retrieved the
instance from Default1
void Page_Load(...)
{...}
void Button1Clicked(...)
{...}
}
Can anyone please explain how a Singleton object created within a Page
class is able to get application scope?
Rich
when it should have had page scope:
public class Singleton
{
private static Singleton uniqueInstance = null;
private Singleton()
{
}
public static Singleton getInstance()
{
if (uniqueInstance == null)
uniqueInstance = new Singleton();
return uniqueInstance;
}
}
public partial class Default1age
{
Singleton s = Singleton.getInstance();
void Page_Load(...)
{...}
void Button1Clicked(...)
{...}
}
public partial class Default2age
{
Singleton s = Singleton.getInstance(); // this retrieved the
instance from Default1
void Page_Load(...)
{...}
void Button1Clicked(...)
{...}
}
Can anyone please explain how a Singleton object created within a Page
class is able to get application scope?
Rich