Events and PostBack

rmatthew

Well-known member
Joined
Dec 30, 2002
Messages
115
Location
Texas
I have a button (actually several controls) but lets start with a button :) that processes some code in the click event.

Problem is that the code for the event is processed after the load event on the postback.

Is there a way to get the code from the click event to process prior to completing the load event?

The click event processes/changes variables that I need to use during the load event.

Any Ideas?
Thanks in advance
 
Variables and items that can be changed in various places in your application should be put inside some sort of InitStuff() function. That way you can call this from the Page_Load event if the Page.IsPostBack is false, and then call the InitStuff() function from the event that fires after changing whatever you need to.

Another way is to use Page_Load(object sender, EventArgs e), in this case the sender is the object that initiated the post back (at least Im pretty sure). You can then take action appropriately.
 
I never use sender in page_load, may I know what type of object will I get in parameter object sender from page_load event?
 
Back
Top