Eventhandling in Page hierarchies, how does it really work ?

Discussion in 'ASP .Net' started by Claes Rådström, Feb 4, 2004.

  1. 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 Rådström, Feb 4, 2004
    #1
    1. Advertising

  2. Claes Rådström

    Ryan Walberg Guest

    Claes Rådström wrote:

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

    --
    Ryan Walberg, B.Sc., MCSD, MCSD for .NET
    am
    Ryan Walberg, Feb 4, 2004
    #2
    1. Advertising

  3. Claes Rådström

    bruce barker Guest

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


    "Claes Rådström" <> wrote in message
    news:...
    > 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
    >
    >
    >
    bruce barker, Feb 4, 2004
    #3
  4. OK, thanks
    looks like the solution i came up with, thru extensive permutation :)

    /C

    "bruce barker" <> wrote in message
    news:...
    > // 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)
    >
    >
    > "Claes Rådström" <> wrote in message
    > news:...
    > > 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 Rådström, Feb 5, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrea
    Replies:
    0
    Views:
    370
    Andrea
    Dec 18, 2003
  2. Herfried K. Wagner [MVP]
    Replies:
    12
    Views:
    566
    =?Utf-8?B?YmFsbWVyY2g=?=
    Dec 1, 2005
  3. cm
    Replies:
    2
    Views:
    2,007
  4. Franz Fitz

    Problem with Eventhandling in user control

    Franz Fitz, Oct 30, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    121
    John Saunders
    Oct 30, 2003
  5. Ralf Müller

    serialization problem - eventhandling by control

    Ralf Müller, Dec 14, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    129
    Ralf Müller
    Dec 24, 2004
Loading...

Share This Page