views:

48

answers:

1

Hi

User control receives same events as Page object and just like Page object also exposes Application, Session, Request and Response objects. I realize UserControl class and Page class both inherit from same TemplateControl class and for that reason share so many of same methods and events.

But then why don’t Asp.Net controls such as TextBox, Label, GridView etc. also derive from same class as Page and UserControl classes – in other words, why would it be a bad idea for controls such as TextBox to have same events ( Page_Load etc ) as UserControl and Page classes do?


Thank you

+1  A: 

The single most probable reason for this would be to minimize the serialization size of auto-event-wireup. Everytime you add an event to a handler in WebForms, its persisted across page requests by serializing it into viewstate. By only exposing methods (which are called in tree fashion) that can be overrided, you save yourself from having to serialize those method calls.

LorenVS
thanx for your help
carewithl