Server-Side Events in ASP.NET 1.1

  • Thread starter Mohammed AlQuraishi
  • Start date
M

Mohammed AlQuraishi

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
 
M

Mohammed AlQuraishi

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
 
M

Marina

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

Mohammed AlQuraishi

Thank you. PreRender should probably work; I'll give it a try.

Mohammed
 

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,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top