Eventhandling in Page hierarchies, how does it really work ?

  • Thread starter Claes Rådström
  • 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
 
R

Ryan Walberg

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?
 
B

bruce barker

// 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)
 
C

Claes Rådström

OK, thanks
looks like the solution i came up with, thru extensive permutation :)

/C
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top