Let’s say I have a System.Web.IHttpHandler whose base class is ASP.login_aspx whose base class is MyCMS.Admin.Login whose base class is… etc… all the way back to System.Web.UI.Page and of course, object.
Why do I have to cast my IHttpHandler as MyCMS.Admin.Login before I can access the members of that type and below?
Example:
IHttpHandler result = base.GetHandler(context, requestType, virtualPath, path);
bool isVisible = result.Visible;//Does not work
bool isVisible = ((MyCMS.Admin.Login)(result)).Visible;//Works
//Noting that Visible is a member of System.Web.UI.Page
For clarity, I’m not expecting that result.Visible should work, I just want to know why it doesn’t.
Visibleis not a member ofIHttpHandler, so you should not expect to be able to call it on such a variable. It’s a member ofPage, by way ofControl, I believe.When you cast a variable to one of the base types/interfaces of the object’s class, you can only call members that are on the type of the variable (or base classes/interfaces of that type).