Need to execute code before events are handled.

revel8r

New member
Joined
Jan 15, 2007
Messages
2
Programming Experience
10+
I have a problem with maintaining a variable during event handling, and here's what I think the situation is:

1) I set a random number in a page_load.
2) Upon a button click, I have a routine to check and see if the number typed = the random number generated in step 1.

The problem is, the submit button click regenerates a new number (by triggering a page_load event) before the routine in step 2 has a chance to do what it needs to do. Therefore, the chances that the two numbers are = are very slim.

Is there a keyword or something that tells vb to execute the routine in #2 before the page_load event is called?

Thanks.
 
page_init instead of page_load

I think i solved the problem by moving the random number generation code to the page_init proc instead. But shouldn't there be a way to order the event handling and proc execution? If so, how?
 
The order of events is set and cannot be altered.

The Page.IsPostBack property can be used to check if the page load is caused by a postback.
 
Back
Top