Dozens of variations on the title of this post are some of the most common searches that bring people here to Encosia. Unfortunately, the search engines all point to a post that doesn’t answer the question. It’s also a frequent question raised on the ASP.NET message boards, typically without a satisfactory answer provided.
However, it is an important question, the answer to which is important to understand. So, in an attempt to fill in this gap for the searchers and perhaps preemptively help others, I want to proceed to answer it as thoroughly as possible without overly complicating the whole business.
In order to do this, we’ll have to take a brief tour of WebForms, including:
- Understanding what the Page class is, and why we have it.
- One specific thing that the Page class does for us.
- How this is accomplished, behind the scenes.
- What the static keyword entails, when used with a method.
- Finally, why page methods must be static.