access level for server control and user control

When we drag and drop any server control from toolbox to web form, the relevant control is added to code-behind automatically with access level to be protected. When we drag and drop a user control to a web form, if we want to use that user control in code-behind, then we need to declare it to be protected as well, otherwise it will not work properly, why??? I never pay attention to this untill I start to work with user control. Thanks zhuang

2 Replies

AD Administrator Syncfusion Team February 28, 2006 03:32 PM UTC

Hi, A nice question, I think the reason should be because "just a guess only" The controls are just reusable classes(the benefit of object oriented concept), and ofcourse the full usage of object oriented features are applied in reusable classes only. So we are in need of a object to refer this classes. But why do we need protected? still confuses but this should be again regarding the protection level is intermediate I guess because if any one wants to use it inside the application or page , they can use the control and the chances of breaking the control outside the application should be avoided , so finally that too makes sense i guess , being protected. If any one have a nice Blogs/discussion on this please post. -Hari


ZH [email protected] March 1, 2006 09:01 AM UTC

Thanks, I have posted the same question on other forums, I will keep this post updated once new answers come in.

Loader.
Up arrow icon