Re: ASP Life Cycle Problem

Discussion in 'ASP .Net' started by S. Justin Gengo, Dec 8, 2003.

  1. Michael,

    Put your code to populate the table web control into a subroutine. Call that
    subroutine in the page load to populate the table with the current session.
    Then call the subroutine again to refresh at the end of the button click
    event.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "Michael Johnson Jr." <> wrote in message
    news:%...
    > I have read that before, someone wrote an article that was very similar to
    > that.
    >
    > Problem is I still don't understand what I need to do.
    >
    > I tried 20+ different ways of doing things and I can't get anywhere, it is
    > getting very fusterating to spend 5 days trying to do something so simple.
    >
    > It all works except for this problem which is causing other problems.
    >
    > I am basically using the Page_Load event to iterate data, populate table

    web
    > contol, which generates buttons on each row and links an event handler to
    > it. But the event handler won't fire unless this method gets called on

    page
    > load even on post back, so that causes the data to reset itself and thus
    > nullifies the point of the button. (It does work, but when you go down

    more
    > than 1 level it fails). If i use a session variable on the button, then I
    > got to click the button twice (cause the page load generates the page with
    > the last settings, then the event button changes the default dir, then

    need
    > another page load to run the new settings).
    >
    > When I do a debug on it, this is what I see.
    >
    > Debug Start.
    >
    >
    > Page Load
    > UpdateTable(Session VAR) (Called from Page_Load)
    > <User Clicks Button>
    > Page_Load()
    > UpdateTable(Session VAR) (Called from Page_Load)
    > Button_Click Event() (Sets session variable)
    >
    > What this does, is causes it to require a second button click (or some

    sort
    > of event to cause the program to do another page refresh with the new
    > session var since the button click isn't handled before the page load).
    >
    >
    > "Kevin Spencer" <> wrote in message
    > news:...
    > > The following link may be useful to you:
    > >
    > >

    >

    http://msdn.microsoft.com/library/d...guide/html/cpconControlExecutionLifecycle.asp
    > >
    > > --
    > > HTH,
    > > Kevin Spencer
    > > .Net Developer
    > > Microsoft MVP
    > > Big things are made up
    > > of lots of little things.
    > >
    > > "Michael Johnson Jr." <> wrote in message
    > > news:...
    > > >
    > > >
    > > > The problem is the following pseudo code causes you need to click

    > buttons
    > > > twice to get event.
    > > >
    > > > This is notable via debugging and single stepping.
    > > >
    > > > I can't seem to quite figure out how to do events in ASP where they

    need
    > > to
    > > > rerender the page.
    > > >
    > > > I been banging my head on this for 4 days now.
    > > >
    > > >
    > > >
    > > >
    > > > Page_Load
    > > >
    > > > If (Page.PostBack)
    > > >
    > > > Session["currentDir"] = App["rootDir"]
    > > >
    > > > updateTable(Session["currentDir"]
    > > >
    > > > updateTable(currentDir)
    > > >
    > > > string[] dirs = Directory.GetDirectories(currentDir)
    > > >
    > > > foreach dir in dirs
    > > >
    > > > button.Attribs["dir"];
    > > >
    > > > button.Click = myButton_click
    > > >
    > > > tCell1.Controls.Add(button)
    > > >
    > > > Tabl1.Rows.Add(tRow)
    > > >
    > > > myButton_click
    > > >
    > > > Session["currentDir"] = button.Attribs["dir"]
    > > >
    > > > // previously I used this statement but I found it caused

    > the
    > > > event to fire twice (cause it wouldn't work period if I didn't have it

    > run
    > > > again in page load
    > > >
    > > > // updateTable(button.Attribs["dir"]
    > > >
    > > >

    > >
    > >

    >
    >
    S. Justin Gengo, Dec 8, 2003
    #1
    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. john doe Jr

    ASP Life Cycle Problem

    john doe Jr, Dec 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    807
    Teemu Keiski
    Dec 5, 2003
  2. prem

    ASP.Net Life Cycle

    prem, Nov 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    468
    Kevin Spencer
    Nov 2, 2004
  3. =?Utf-8?B?amlt?=

    Life cycle of ASP .NET Application

    =?Utf-8?B?amlt?=, Jan 18, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    7,801
    Juan T. Llibre
    Jan 19, 2005
  4. Guest
    Replies:
    3
    Views:
    2,774
    Bruce Barker
    Sep 6, 2005
  5. Umut Tezduyar

    Control Life Cycle in Asp.Net 2.0

    Umut Tezduyar, Nov 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,255
    Umut Tezduyar
    Nov 16, 2005
Loading...

Share This Page