在aspx.cs上定义属性,比如:
然后重写dispose()方法,如下:
这样就可以及时释放资源,而且方便管理
#region
属性块
private int _taskID = 0 ;
public int TaskID
{
get
{
return _taskID;
}
set
{
if (String.IsNullOrEmpty(value.ToString()))
{
throw new ArgumentNullException(value.ToString(), " null value for TaskID " );
}
if ( ! XPWY.Utility.WebValidate.IsInteger(value.ToString()))
{
throw new InvalidCastException( " invalidCastException for TaskID " );
}
_taskID = value;
}
}
private TQL_Section ts = null ;
private TQL_Task tt = null ;
/// <summary>
/// TQL_TopQuestionTitle
/// </summary>
private IList < TQL_TopQuestionTitle > ttq = null ;
/// <summary>
/// TQL_QuestionTitle
/// </summary>
private IList < TQL_QuestionTitle > tqt = null ;
/// <summary>
/// TQL_ChoiceVoice
/// </summary>
private IList < TQL_ChoiceVice > tcv = null ;
private int QuestionFirstNum = 0 ;
private int QuestionSecondNum = 0 ;
#endregion
private int _taskID = 0 ;
public int TaskID
{
get
{
return _taskID;
}
set
{
if (String.IsNullOrEmpty(value.ToString()))
{
throw new ArgumentNullException(value.ToString(), " null value for TaskID " );
}
if ( ! XPWY.Utility.WebValidate.IsInteger(value.ToString()))
{
throw new InvalidCastException( " invalidCastException for TaskID " );
}
_taskID = value;
}
}
private TQL_Section ts = null ;
private TQL_Task tt = null ;
/// <summary>
/// TQL_TopQuestionTitle
/// </summary>
private IList < TQL_TopQuestionTitle > ttq = null ;
/// <summary>
/// TQL_QuestionTitle
/// </summary>
private IList < TQL_QuestionTitle > tqt = null ;
/// <summary>
/// TQL_ChoiceVoice
/// </summary>
private IList < TQL_ChoiceVice > tcv = null ;
private int QuestionFirstNum = 0 ;
private int QuestionSecondNum = 0 ;
#endregion
释放资源
#region 释放资源
/**//// <summary>
/// 释放资源
/// </summary>
public override void Dispose()
...{
if (ts != null)
ts = null;
if (tt != null)
tt = null;
if (ttq != null)
ttq = null;
if (tqt != null)
tqt = null;
if (tcv != null)
tcv = null;
base.Dispose();
}
#endregion
/**//// <summary>
/// 释放资源
/// </summary>
public override void Dispose()
...{
if (ts != null)
ts = null;
if (tt != null)
tt = null;
if (ttq != null)
ttq = null;
if (tqt != null)
tqt = null;
if (tcv != null)
tcv = null;
base.Dispose();
}
#endregion