Choose a location:
Hi,
I have one web form. In the webform i have overrided Control.AddedControl method like below,
protected void Page_Load(object sender, EventArgs e) { Response.Write("This is the page load event</br>");
} protected override void AddedControl(Control control, int index) { Response.Write("we are in AddedControl eventhandler</br>"); }
I am getting the output as,
we are in AddedControl eventhandlerwe are in AddedControl eventhandlerwe are in AddedControl eventhandlerwe are in AddedControl eventhandlerwe are in AddedControl eventhandlerThis is the page load event
Now i have overrided one more method AddParsedSubObject like below,
protected override void protected override void AddParsedSubObject(object obj) { Response.Write("we are in AddParsedSubObject eventhandler</br>"); } protected void Page_Load(object sender, EventArgs e) { Response.Write("This is the page load event</br>");
} protected override void AddedControl(Control control, int index) { Response.Write("we are in AddedControl eventhandler</br>"); }(object obj) { Response.Write("we are in AddParsedSubObject eventhandler</br>"); } Now the output is,
we are in AddParsedSubObject eventhandlerwe are in AddParsedSubObject eventhandlerwe are in AddParsedSubObject eventhandlerwe are in AddParsedSubObject eventhandlerwe are in AddParsedSubObject eventhandlerThis is the page load event
After adding the AddParsedSubObject method if i try to debug the code, execution is not comming in the AddedControl method. The output shows that clearly.
can anyone explain that?
Thanks in advance
The reason for this behavior is that AddedControl event is a sub-event of AddedParsedSubObject event. So if you are overriding AddedParsedObject, overrriden AddedControl wont fire as it is nested inside AddedParseSubObject.
HTH,
Vivek
Got my answer. Thanks Vivek