自定义类存储性能和跨页通过它的实例 - ASP.NET
-
26-09-2019 - |
题
我有,我需要在页面之间传递一些对象的要求。所以,我创建了一个自定义类的所有属性所需,创造它的一个实例,并适当地分配给所有属性。然后我把这个对象的会话,并把它的其他页面。
的问题是,甚至当我设置的属性值的类它是未来为空。我设置在吸气剂-setter和锯断点该值本身就要为空。
代码 -
public class GetDataSetForReports
{
private Table m_aspTable;
private int m_reportID;
private string m_accountKey;
private string m_siteKey;
private string m_imUserName;
/// <summary>
/// Asp Table containing the filters
/// </summary>
public Table aspTable
{
get
{
return m_aspTable;
}
set
{
m_aspTable = aspTable;
}
}
/// <summary>
/// Report ID
/// </summary>
public int reportID
{
get
{
return m_reportID;
}
set
{
m_reportID = reportID;
}
}
/// <summary>
/// All the accounts selected
/// </summary>
public string accountKey
{
get
{
return m_accountKey;
}
set
{
m_accountKey = accountKey;
}
}
/// <summary>
/// All the sites selected
/// </summary>
public string siteKey
{
get
{
return m_siteKey;
}
set
{
m_siteKey = siteKey;
}
}
/// <summary>
/// Current User Name
/// </summary>
public string imUserName
{
get
{
return m_imUserName;
}
set
{
m_imUserName = imUserName;
}
}
}
这是如何我在第1页创建一个实例,并试图让它在第2页。
第1页代码
//Add the objects to the GetDataSetForReports Class
GetDataSetForReports oGetDSForReports = new GetDataSetForReports();
oGetDSForReports.aspTable = aspTable;
oGetDSForReports.reportID = iReportID;
oGetDSForReports.accountKey = AccountKey;
oGetDSForReports.siteKey = Sitekey;
oGetDSForReports.imUserName = this.imUserName.ToString();
但是,这些值没有得到设定的。该值是不是在所有传递给类(给setter)。 am我作出任何错误OOP?
任何想法?
NLV
解决方案
和笨傻。它必须是“价值”而不是在设定器的公共变量的
不隶属于 StackOverflow