private code-behind methods ignored by the compiler - ASP.NET

asp.net

Solution

Your ASPX page is not the same class as your code behind page. It inherits it and therefore it cannot see the private members. This is why they must be protected or public.

Problem

When declaring a code-behind method as private (such as an event handler), the compiler ignores it and outputs: "Compiler Error Message: CS1061: 'ASP.default_aspx' does not contain a definition for 'OnLoginUser' and no extension method 'OnLoginUser' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)" In practice, OnLoginUsed does exist, and when the identifier is changed to "public\protected" everything works just fine. The question is why it is impossible to declare such method as private? after all, it's being called internally by other members of the class. 10x!

Original source