Who Calls the First OnLoad Call in Page
asp.net 3.5 Ive been sitting with the Reflector to find out - who is First(!) calling the OnLoad Method which activates the event for all subscribers i didnt find it.
im not talking about the AutoEvenntWireup situation ( which is not relevant here) because this开发者_如何学Go stage happens later...
im talking about : who first Activates the Control.OnLoad Method ?? i want to see it in the reflector and could find the activation ! i can find only the Method signature
Page.ProcessRequestMain()
calls Page.LoadRecursive()
, which in turn calls Page.OnLoad()
.
The relevant code (disassembled with ILSpy) is:
internal virtual void LoadRecursive()
{
if (this._controlState < ControlState.Loaded) {
if (this._adapter != null) {
this._adapter.OnLoad(EventArgs.Empty);
} else {
this.OnLoad(EventArgs.Empty); // ** Here. **
}
}
if (this._occasionalFields != null
&& this._occasionalFields.Controls != null) {
string collectionReadOnly
= this._occasionalFields.Controls.SetCollectionReadOnly(
"Parent_collections_readonly");
int count = this._occasionalFields.Controls.Count;
for (int i = 0; i < count; i++) {
this._occasionalFields.Controls[i].LoadRecursive();
}
this._occasionalFields.Controls.SetCollectionReadOnly(
collectionReadOnly);
}
if (this._controlState < ControlState.Loaded) {
this._controlState = ControlState.Loaded;
}
}
精彩评论