Inherited page events not being hit

A

AC [MVP MCMS]

I feel like I'm missing something so simple...

I have a page (start.aspx) whose code behind is
public class Start : AdminPage
{
override protected void OnInit(EventArgs e)
{
base.OnInit(e);
int x=1;
}
}


And my AdminPage class looks like this:
public class AdminPage : System.Web.UI.Page
{
override protected void OnInit(EventArgs e)
{
int x=1;
}
}

No, it's not really this simple, but I'm removing my custom stuff to keep it
simple for this question. Anyway, I build and set a breakpoint in the
AdminPage.OnInit assignment and it never stops... but it does stop on the
Start OnInit if I do the same thing... ideas? I'm flat out lost.
 
K

Karl Seguin

Andrew:
If I copy your code exactly into vs.net:

using System;
using System.Web.UI;

namespace TestCS
{
public class Start : AdminPage
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
int x = 1;
}
}

public class AdminPage : Page
{
protected override void OnInit(EventArgs e)
{
int x = 1;
}
}
}

and debug it, I hit both OnInit...your AdminPage should probably also call
base.OnInit(e) but that won't solve your problem......have you tried the
simple example without all the stuff or did you just strip some stuff out
for our benefit?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
K

Karl Seguin

We should be attending some of the same teched sessions, see you there :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
AC said:
<ignore my post />

see: stupid overlooked error

--
-AC [MVP MCMS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp


Karl Seguin said:
Andrew:
If I copy your code exactly into vs.net:

using System;
using System.Web.UI;

namespace TestCS
{
public class Start : AdminPage
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
int x = 1;
}
}

public class AdminPage : Page
{
protected override void OnInit(EventArgs e)
{
int x = 1;
}
}
}

and debug it, I hit both OnInit...your AdminPage should probably also
call base.OnInit(e) but that won't solve your problem......have you tried
the simple example without all the stuff or did you just strip some stuff
out for our benefit?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top