is this a hack?

Discussion in 'ASP .Net' started by foldface@yahoo.co.uk, Jul 13, 2004.

  1. Guest

    Hi
    I commonly have the problem that given a page with 2+ usercontrols
    many of the pages events occur before the childs, e.g. PageLoad, because
    of this I wind up moving code from PageLoad to PreRender. This doesn't
    feel right.

    More info:
    (1) I put code in Page_Load in the usercontrols so that all the ViewState
    and other stuff has loaded in
    (2) I put code in PreRender in the parent because of this
    (3) Given a page with a usercontrol(1) which itself holds a UserControl(2) then
    as the PreRender for the UserControl happens second then I could wind up
    with Control2 having code in PageLoad, Control1 having code in PreRender
    and the page having code in Render to ensure the right loading order

    To get around this I've though of making a class that takes as arguments
    a number of events, e.g. the Page_Loads of the child UserControls,
    and once all of these have fired it calls some other event,
    e.g. Page_Load2, of the parent.
    This feels like a solution that will work but possibly still not
    the best way of doing things. The page itself could also do this
    but thats more of less the same thing.

    Any feedback? Are there any asp.net patterns about the place?

    Ta
    F
     
    , Jul 13, 2004
    #1
    1. Advertising

  2. Kyril Magnos Guest

    Well, you are correct about it not feeling right. You need to examine how
    you are reloading your controls when a postback occurs. First off, make sure
    that you are checking to see if this is a postback using Page.IsPostBack.
    Secondly, you need to reload your controls in EXACTLY the same order,
    everytime, so that the ASP.NET runtime can recreate the control tree
    accurately. Then, events should fire in the proper order.

    HTH,

    Kyril


    <> wrote in message
    news:...
    > Hi
    > I commonly have the problem that given a page with 2+ usercontrols
    > many of the pages events occur before the childs, e.g. PageLoad, because
    > of this I wind up moving code from PageLoad to PreRender. This doesn't
    > feel right.
    >
    > More info:
    > (1) I put code in Page_Load in the usercontrols so that all the ViewState
    > and other stuff has loaded in
    > (2) I put code in PreRender in the parent because of this
    > (3) Given a page with a usercontrol(1) which itself holds a UserControl(2)
    > then
    > as the PreRender for the UserControl happens second then I could wind up
    > with Control2 having code in PageLoad, Control1 having code in PreRender
    > and the page having code in Render to ensure the right loading order
    >
    > To get around this I've though of making a class that takes as arguments
    > a number of events, e.g. the Page_Loads of the child UserControls,
    > and once all of these have fired it calls some other event,
    > e.g. Page_Load2, of the parent.
    > This feels like a solution that will work but possibly still not
    > the best way of doing things. The page itself could also do this
    > but thats more of less the same thing.
    >
    > Any feedback? Are there any asp.net patterns about the place?
    >
    > Ta
    > F
     
    Kyril Magnos, Jul 13, 2004
    #2
    1. Advertising

  3. Guest

    , Jul 14, 2004
    #3
    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. Ing. Rajesh Kumar
    Replies:
    2
    Views:
    9,506
    Kevin Spencer
    Jul 7, 2004
  2. Jeffrey

    Hack Attempt?

    Jeffrey, Aug 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,459
    Jeffrey
    Aug 4, 2005
  3. Edwin Knoppert

    ASP.NET 2005 hack-proof?

    Edwin Knoppert, Dec 2, 2005, in forum: ASP .Net
    Replies:
    17
    Views:
    637
    Kevin Spencer
    Dec 2, 2005
  4. =?Utf-8?B?QmlsbCBTZW1wZg==?=

    View state hack for spammers?

    =?Utf-8?B?QmlsbCBTZW1wZg==?=, Mar 13, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    770
    =?Utf-8?B?QmlsbCBTZW1wZg==?=
    Mar 13, 2006
  5. =?iso-8859-1?Q?Nils_O=2E_Sel=E5sdal?=

    WindowsLookAndFeel on non-Windows hack

    =?iso-8859-1?Q?Nils_O=2E_Sel=E5sdal?=, Oct 25, 2003, in forum: Java
    Replies:
    1
    Views:
    1,574
    Steve W. Jackson
    Oct 27, 2003
Loading...

Share This Page