access level of user control in code-behind

Z

zhuang

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
 
M

MSDN

Protected
Protected means that elements are accessible only from within their own
class or from a derived class. Protected can also be used with the Friend
keyword. When they're used together, elements are accessible from the same
assembly, from their own class, and from any derived classes.

in "Code Front"

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

Inhertis the code behind page so when you declare protected then you can use
it.

You can do Public but do you really want too?? NOT.

SA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top