Page_Load in connection class

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"%>
 
M

Marina

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top