views:

114

answers:

1

On a UserControl in asp.net webforms, Why do the controls within the usercontrol (TextBox, DropDownList, etc.) have to be declared as protected in the code-behind. Is there runtime inheritance occuring with webforms?

+1  A: 

In case of Web Application it's compile-time rather then run-time (in Web Sites, however, the compilation is purely run-time).

What happens is as follows. ASP.NET merges your ascx file and your code-behind class into a brand new class, which contains all the markup from your ascx file added to Render() methods of a newly created control.

Anton Gogolev