Why is Page Load event in ASP.Net is marked as Protected

Last Reply on May 10, 2013 05:45 AM By Mudassar

Posted on May 10, 2013 05:43 AM

Usually when we create an aspx page and then open the aspx.cs page we can see a protected void page_load().So my question is why that should be protected in default.Can we give other access modifiers.Can you help me with an example

Posted on May 10, 2013 05:45 AM

It is protected since your .CS page is a partial class and the ASPX page inherits the class

And when a we inherit some class we can access its protected as well as public methods

You can make the page_load event as public also and it will work but it will also expose the methods to other Classes and ASPX pages, which is not good

But you cannot make the page_load event as private as then it won't be available anywhere outside the class


I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html