Server-Side Events in ASP.NET 1.1

Discussion in 'ASP .Net' started by Mohammed AlQuraishi, Jan 7, 2005.

  1. Hi,

    I'm having trouble with synchronizing the order of server-side events, and I
    was hoping someone here can shed some light on what's happening. In a
    simplified version, I click on a button which changes the contents of a
    textbox, something like:

    private void btn_Click(object sender, System.EventArgs e)
    {
    TextBox1.Text = "I've changed";
    }

    Clicking the button changes TextBox1 as expected. Now, in the Page_Load
    event, I'm trying to copy the contents of this textbox into another, like
    this:

    private void Page_Load(object sender, System.EventArgs e)
    {
    TextBox2.Text = TextBox1.Text;
    }

    Clicking the button once does not change TextBox2, suggesting that TextBox1
    was changed AFTER Page_Load was invoked. I know that Page_Load is being
    invoked because if I were to click the button again, TextBox2 does in fact
    change. Why is this happening? Shouldn't the button post all the changes, at
    which point Page_Load should pick them up? I.e. why is Page_Load being
    executed after the contents of btn_Click(...) are excuted? And how can this
    be changed?

    Thanks for any information.

    Mohammed
    Mohammed AlQuraishi, Jan 7, 2005
    #1
    1. Advertising

  2. Mohammed AlQuraishi

    Marina Guest

    Page_Load happens before any event handlers for the server side UI objects.

    "Mohammed AlQuraishi" <> wrote in message
    news:%...
    > Hi,
    >
    > I'm having trouble with synchronizing the order of server-side events, and

    I
    > was hoping someone here can shed some light on what's happening. In a
    > simplified version, I click on a button which changes the contents of a
    > textbox, something like:
    >
    > private void btn_Click(object sender, System.EventArgs e)
    > {
    > TextBox1.Text = "I've changed";
    > }
    >
    > Clicking the button changes TextBox1 as expected. Now, in the Page_Load
    > event, I'm trying to copy the contents of this textbox into another, like
    > this:
    >
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > TextBox2.Text = TextBox1.Text;
    > }
    >
    > Clicking the button once does not change TextBox2, suggesting that

    TextBox1
    > was changed AFTER Page_Load was invoked. I know that Page_Load is being
    > invoked because if I were to click the button again, TextBox2 does in fact
    > change. Why is this happening? Shouldn't the button post all the changes,

    at
    > which point Page_Load should pick them up? I.e. why is Page_Load being
    > executed after the contents of btn_Click(...) are excuted? And how can

    this
    > be changed?
    >
    > Thanks for any information.
    >
    > Mohammed
    >
    >
    Marina, Jan 7, 2005
    #2
    1. Advertising

  3. Thanks for your reply. Is there an event that occurs after all other
    handlers? The problem is that I have a piece of code that needs to be
    executed every time the page is loaded. This code also checks on some
    variables, which the button click changes. I want those changes to be
    affected before the Page_Load code executes. Where else ought I put it?

    Thanks.

    Mohammed

    "Marina" <> wrote in message
    news:...
    > Page_Load happens before any event handlers for the server side UI
    > objects.
    >
    > "Mohammed AlQuraishi" <> wrote in message
    > news:%...
    >> Hi,
    >>
    >> I'm having trouble with synchronizing the order of server-side events,
    >> and

    > I
    >> was hoping someone here can shed some light on what's happening. In a
    >> simplified version, I click on a button which changes the contents of a
    >> textbox, something like:
    >>
    >> private void btn_Click(object sender, System.EventArgs e)
    >> {
    >> TextBox1.Text = "I've changed";
    >> }
    >>
    >> Clicking the button changes TextBox1 as expected. Now, in the Page_Load
    >> event, I'm trying to copy the contents of this textbox into another, like
    >> this:
    >>
    >> private void Page_Load(object sender, System.EventArgs e)
    >> {
    >> TextBox2.Text = TextBox1.Text;
    >> }
    >>
    >> Clicking the button once does not change TextBox2, suggesting that

    > TextBox1
    >> was changed AFTER Page_Load was invoked. I know that Page_Load is being
    >> invoked because if I were to click the button again, TextBox2 does in
    >> fact
    >> change. Why is this happening? Shouldn't the button post all the changes,

    > at
    >> which point Page_Load should pick them up? I.e. why is Page_Load being
    >> executed after the contents of btn_Click(...) are excuted? And how can

    > this
    >> be changed?
    >>
    >> Thanks for any information.
    >>
    >> Mohammed
    >>
    >>

    >
    >
    Mohammed AlQuraishi, Jan 7, 2005
    #3
  4. Mohammed AlQuraishi

    Marina Guest

    There are PreRender and Unload events that occur after all the server side
    UI object events.

    "Mohammed AlQuraishi" <> wrote in message
    news:%...
    > Thanks for your reply. Is there an event that occurs after all other
    > handlers? The problem is that I have a piece of code that needs to be
    > executed every time the page is loaded. This code also checks on some
    > variables, which the button click changes. I want those changes to be
    > affected before the Page_Load code executes. Where else ought I put it?
    >
    > Thanks.
    >
    > Mohammed
    >
    > "Marina" <> wrote in message
    > news:...
    > > Page_Load happens before any event handlers for the server side UI
    > > objects.
    > >
    > > "Mohammed AlQuraishi" <> wrote in message
    > > news:%...
    > >> Hi,
    > >>
    > >> I'm having trouble with synchronizing the order of server-side events,
    > >> and

    > > I
    > >> was hoping someone here can shed some light on what's happening. In a
    > >> simplified version, I click on a button which changes the contents of a
    > >> textbox, something like:
    > >>
    > >> private void btn_Click(object sender, System.EventArgs e)
    > >> {
    > >> TextBox1.Text = "I've changed";
    > >> }
    > >>
    > >> Clicking the button changes TextBox1 as expected. Now, in the Page_Load
    > >> event, I'm trying to copy the contents of this textbox into another,

    like
    > >> this:
    > >>
    > >> private void Page_Load(object sender, System.EventArgs e)
    > >> {
    > >> TextBox2.Text = TextBox1.Text;
    > >> }
    > >>
    > >> Clicking the button once does not change TextBox2, suggesting that

    > > TextBox1
    > >> was changed AFTER Page_Load was invoked. I know that Page_Load is being
    > >> invoked because if I were to click the button again, TextBox2 does in
    > >> fact
    > >> change. Why is this happening? Shouldn't the button post all the

    changes,
    > > at
    > >> which point Page_Load should pick them up? I.e. why is Page_Load being
    > >> executed after the contents of btn_Click(...) are excuted? And how can

    > > this
    > >> be changed?
    > >>
    > >> Thanks for any information.
    > >>
    > >> Mohammed
    > >>
    > >>

    > >
    > >

    >
    >
    Marina, Jan 7, 2005
    #4
  5. Thank you. PreRender should probably work; I'll give it a try.

    Mohammed

    "Marina" <> wrote in message
    news:%...
    > There are PreRender and Unload events that occur after all the server side
    > UI object events.
    >
    > "Mohammed AlQuraishi" <> wrote in message
    > news:%...
    >> Thanks for your reply. Is there an event that occurs after all other
    >> handlers? The problem is that I have a piece of code that needs to be
    >> executed every time the page is loaded. This code also checks on some
    >> variables, which the button click changes. I want those changes to be
    >> affected before the Page_Load code executes. Where else ought I put it?
    >>
    >> Thanks.
    >>
    >> Mohammed
    >>
    >> "Marina" <> wrote in message
    >> news:...
    >> > Page_Load happens before any event handlers for the server side UI
    >> > objects.
    >> >
    >> > "Mohammed AlQuraishi" <> wrote in message
    >> > news:%...
    >> >> Hi,
    >> >>
    >> >> I'm having trouble with synchronizing the order of server-side events,
    >> >> and
    >> > I
    >> >> was hoping someone here can shed some light on what's happening. In a
    >> >> simplified version, I click on a button which changes the contents of
    >> >> a
    >> >> textbox, something like:
    >> >>
    >> >> private void btn_Click(object sender, System.EventArgs e)
    >> >> {
    >> >> TextBox1.Text = "I've changed";
    >> >> }
    >> >>
    >> >> Clicking the button changes TextBox1 as expected. Now, in the
    >> >> Page_Load
    >> >> event, I'm trying to copy the contents of this textbox into another,

    > like
    >> >> this:
    >> >>
    >> >> private void Page_Load(object sender, System.EventArgs e)
    >> >> {
    >> >> TextBox2.Text = TextBox1.Text;
    >> >> }
    >> >>
    >> >> Clicking the button once does not change TextBox2, suggesting that
    >> > TextBox1
    >> >> was changed AFTER Page_Load was invoked. I know that Page_Load is
    >> >> being
    >> >> invoked because if I were to click the button again, TextBox2 does in
    >> >> fact
    >> >> change. Why is this happening? Shouldn't the button post all the

    > changes,
    >> > at
    >> >> which point Page_Load should pick them up? I.e. why is Page_Load being
    >> >> executed after the contents of btn_Click(...) are excuted? And how can
    >> > this
    >> >> be changed?
    >> >>
    >> >> Thanks for any information.
    >> >>
    >> >> Mohammed
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >
    Mohammed AlQuraishi, Jan 7, 2005
    #5
    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. Mong
    Replies:
    5
    Views:
    4,702
    Kevin Spencer
    May 7, 2004
  2. Stuart Whiteford
    Replies:
    2
    Views:
    734
    Stuart Whiteford
    Apr 25, 2006
  3. Mike
    Replies:
    3
    Views:
    404
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Sep 9, 2007
  4. Andrew Stokes
    Replies:
    2
    Views:
    425
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    336
    Chris
    Aug 30, 2005
Loading...

Share This Page