日志不说谎--Asp.net的生命周期
这个问题解决掉了,要想知道为什么Page.IsPostBack为true,就要看看Asp.net中是怎么实现这个属性的;
打开Reflector,依次点开System.Web.UI.Page
public bool get_IsPostBack()
{
if (this._requestValueCollection != null)
{
if (this._isCrossPagePostBack)
{
return true;
}
if (this._pageFlags[8])
{
return false;
}
if ((this.Context.ServerExecuteDepth <= 0) || ((this.Context.Handler != null) && (base.GetType() == this.Context.Handler.GetType())))
{
return !this._fPageLayoutChanged;
}
}
return false;
}
IsPostBack由两个因素决定:1.request value collection (form post collection) if that's missing then it's not postback straight away. 2.detected if data coming from ViewState contains same hash code as on previous request ,that is if the hash code doesn't match then it is not a postback
打开Reflector,依次点开System.Web.UI.Page
public bool get_IsPostBack()
{
if (this._requestValueCollection != null)
{
if (this._isCrossPagePostBack)
{
return true;
}
if (this._pageFlags[8])
{
return false;
}
if ((this.Context.ServerExecuteDepth <= 0) || ((this.Context.Handler != null) && (base.GetType() == this.Context.Handler.GetType())))
{
return !this._fPageLayoutChanged;
}
}
return false;
}
IsPostBack由两个因素决定:1.request value collection (form post collection) if that's missing then it's not postback straight away. 2.detected if data coming from ViewState contains same hash code as on previous request ,that is if the hash code doesn't match then it is not a postback