Page_Load in connection class

  • Thread starter Thread starter Steven K
  • Start date Start date
S

Steven K

Hello,

I created a connection class that has a Page_Load event (MyClass.vb). In
the Page_Load event, I have a response.write("hello world") statement. When
I include this class in my .net page (Steven.aspx), I don't get "hello
world" on my web page. My question is, how does the Page_Load event in a
connection get called?

<%@ Page Inherits="DataConnection" src="cnnData.vb" Explicit="True"
Debug="True"%>
 
Your page should either inherit from a class by using the Inherits
attribute, which should be Namespace.ClassName type of format. Or, it should
have a Src attribute, to point to the source file for the code behind class.
It shouldn't do both, as that doesn't really make any sense.

Now, the class in your code behind file, can inherit from a class other then
Page (as long as somewhere down the line the class you are inheriting from
does inherit from Page). That will allow you to have inheritance in your
pages.

The 'Inherits' attribute is a misleading name, as it really defines the
compiled classname that should be used as the codebehind class. This is
because no matter which you use, Inherits or Src, in reality the page will
end up inheriting from that class, even though it's not really obvious.
 
Back
Top