.NET -Web Service: Why are modifiers Protected instead of Private

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • selvakumaranj
    New Member
    • Nov 2007
    • 3

    .NET -Web Service: Why are modifiers Protected instead of Private

    I am new to .net. Why we are using web server control access modifier as
    protected instead private (even we are using private in winforms control)?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by selvakumaranj
    I am new to .net. Why we are using web server control access modifier as
    protected instead private (even we are using private in winforms control)?
    Hi Selvakumaranj!

    I believe that it's because you need to allow partial controls to access these variables/functions.

    Could you please use a more descriptive title in your future posts.
    "Hi there" is not very descriptive and does not reflect the problem that you are facing. I am changing your title so that it is more meaningful. Please review the posting guidelines, specifically the section on Use a good thread title for more information on why this is important.

    Thanks

    -Frinny

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Have a look at:
      Pretty much every object oriented programming language let's you set the visibility of object members. Usually it defaults to public . That...

      Comment

      • selvakumaranj
        New Member
        • Nov 2007
        • 3

        #4
        Originally posted by Frinavale
        Hi Selvakumaranj!

        I believe that it's because you need to allow partial controls to access these variables/functions.

        Could you please use a more descriptive title in your future posts.
        "Hi there" is not very descriptive and does not reflect the problem that you are facing. I am changing your title so that it is more meaningful. Please review the posting guidelines, specifically the section on Use a good thread title for more information on why this is important.

        Thanks

        -Frinny

        Thanks for your reply. From now onwards i will use descriptive title.

        While declaring controls
        In Winforms:
        private System.Windows. Forms.Button button1;

        In webforms:
        protected System.Web.UI.W ebControls.Butt on Button1;
        why?

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Originally posted by selvakumaranj
          Thanks for your reply. From now onwards i will use descriptive title.

          While declaring controls
          In Winforms:
          private System.Windows. Forms.Button button1;

          In webforms:
          protected System.Web.UI.W ebControls.Butt on Button1;
          why?
          This has to do with letting the ASP code call the Server Side code for the button. If it were private, then the ASP code would not be able to access it.

          Comment

          • selvakumaranj
            New Member
            • Nov 2007
            • 3

            #6
            Originally posted by Frinavale
            This has to do with letting the ASP code call the Server Side code for the button. If it were private, then the ASP code would not be able to access it.
            Thank you very much buddy.

            Comment

            Working...