用于存储属性并跨页面传递其实例的自定义类-ASP.NET
我有一个要求,我需要在页面上传递一些对象。因此,我创建了一个具有所有必需属性的自定义类,并创建了它的一个实例,并适当地分配了所有属性。然后,我将该对象放在会话中,并将其放到另一页 问题是,即使我将属性值设置为类,它也是空的。我在getter setter中设置了一个断点,并看到值本身为null 代码-用于存储属性并跨页面传递其实例的自定义类-ASP.NET,asp.net,oop,getter-setter,Asp.net,Oop,Getter Setter,我有一个要求,我需要在页面上传递一些对象。因此,我创建了一个具有所有必需属性的自定义类,并创建了它的一个实例,并适当地分配了所有属性。然后,我将该对象放在会话中,并将其放到另一页 问题是,即使我将属性值设置为类,它也是空的。我在getter setter中设置了一个断点,并看到值本身为null 代码- public class GetDataSetForReports { private Table m_aspTable; private int m_reportID;
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;
}
}
}
但这些值根本没有设定。这些值根本没有传递给类(传递给setter)。我犯了什么OOP错误吗
有什么想法吗
NLV既愚蠢又愚蠢。它必须是“value”而不是setter中的公共变量。但是有人能告诉我什么是“value”吗?你不能编辑你的问题而不是添加信息作为答案吗?这不是答案,所以不要将其作为答案添加。抱歉。那么答案应该是什么呢?
//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();