Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7633503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:54:11+00:00 2026-05-31T06:54:11+00:00

i always saw that whenever we drag any control on design surface then its

  • 0

i always saw that whenever we drag any control on design surface then its access modifier become protected….why it is protected by default…why not private or public.

i got few answers from few people

1) ts beacuse of the scope of of the protected access modifier, as we know,A protected member is accessible from within the class in which it is declared, and from within any class derived from the class that declared this member.and we know that every .net control is internally a class.
A protected member of a base class is accessible in a derived class only if the access takes place through the derived class type.

2) It is protected due to inheritence between code behind and the aspx.cs file. If you dont want it to be inherited you can make it private or sealed

3) i think u point toward right direction….would u plzz come with a sample code just to show the relation between aspx and code behind and the usage of protected modifier which is important.

no answer gave in detail. so please tell me in detail what kind of relation is there as a result any control’s access modifier is protected?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:54:13+00:00Added an answer on May 31, 2026 at 6:54 am

    Typically, when ASP.NET compiles aspx page, the generated page class is inherited from the code-behind class. The code that instantiates actual controls and build the control tree resides in the generated class. Because of such relation-ship, the designer by default assigns the protected scope to the control variables that gets declared in designer.cs file (which is essentially same as code-behind class). Because of protected scope, these variables become accessible in the actual page class (generated by ASP.NET compiler) and hence the page class code can actually initialize them to correct control instances.

    The public scope will also work but it violates encapsulation because typically control instances on the page are not needed to be referred out side the page class. The private scope will not work because it means the control variables would be accessible only within the code-behind class and hence, the page class (which gets derived from code-behind class) cannot set the variable to the control instance. In such case, you will find that the control variable will have null value in the code-behind class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The implementation of file compressors that I saw was always compressing arrays of bytes.
I'm fighting here with System.Printing namespace of .net framework. And what i always saw
I always felt that expecting exceptions to be thrown on a regular basis and
In some enterprise-like project (.NET, WCF) i saw that all service contracts accept a
I saw here that: As you probably already know, relying on client-side validation alone
I'm trying to pass some variables from PHP to JS. I saw here that
I saw a tweet recently that confused me (this was posted by an XNA
I'm always surprised that even after using C# for all this time now, I
I was poking around in XNA and saw that the Vector3 class in it
I want to have a generic thread safe collection and I saw that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.