Eventhandling in Page hierarchies, how does it really work ?

  • Thread starter Thread starter Claes Rådström
  • Start date Start date
C

Claes Rådström

Hi !

We have a base class that derives from System.Web.UI.Page

Alla our pages derives from it.
In our base class we want to have an access check, (own) , to verfy user
access to the derived page.
We want this in the base class so that the programmer cant forget to
implement it.
=> we want a page load in the base class to fire first, if access is granted
then proceed to derived page load
and do other stuff.

This event mix with base classes, derived pages tends to be pretty messy.
Today we are using OnLoad in base class but this feels like a diry solution.

Anyone that can give a reference/ shine some light on o eventhandling in asp
page hierachies
or have a "solution" to the given problem above ??

Thanks
/Claes
 
Claes said:
Hi !

We have a base class that derives from System.Web.UI.Page

Alla our pages derives from it.
In our base class we want to have an access check, (own) , to verfy user
access to the derived page.
We want this in the base class so that the programmer cant forget to
implement it.

Where is the user's identity stored?
 
// my base page

public class myBasePage : Page
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
// create any dynamic controls here that want to recieve postback
data
}
protected override void OnLoad(EventArgs e)
{
// any code i want before page_load fires
base.OnLoad(e); // this routine fires the onload event to
all on load delegates
// any code i want after page_load fires
}
}

// apsx code behind
public class myPage : myBasePage
{
private void Page_Load(object sender, System.EventArgs e)
{
}
}


-- bruce (sqlwork.com)
 
OK, thanks
looks like the solution i came up with, thru extensive permutation :)

/C
 
Back
Top