How to use Page_Load event in a Class

S

Steven K

Hello,

I have created a simple Class:

Public Class DataConnection : Inherits Page
Public Sub Page_Load(Sender As Object, E As EventArgs)
Response.Write("Hello Steven")
End Sub
End Class

The question I have is, how does the Page_Load event in the Class act when
it is being pulled into an aspx page?

<%@ Page Inherits="DataConnection" src="cnnData.vb" Language="VB"
Explicit="True" Debug="True"%>
 
K

Kevin Spencer

According to your code, the Page you're creating IS the DataConnection
class.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
S

Steven K

Sorry for the vagueness. The class DataConnection is in a file named
cnnData.vb and the aspx file that is calling it is myfile.aspx. What I'm
trying to ask is why don't I get the text "Hello Steven" when myfile.aspx is
loaded since it is calling cnnData.vb? Also, is it ok to have a Page_Load
sub in both files?
 

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