static variables in page_load event handler

C

Carlos

Hi all,

I just tried to use a static variable within the scope of the
page_load event handler, but apparently it did not work
all I wanted to do is to evaluate the postback condition
and initialize the variable, when the condition was not met assign
its value to a member class variable, and use it in the
button_click event handler. However, the variable does not
maintain its initial value. It gets wiped out before I am able
to assign it to a variable with the scope of the class.

Can anybody helo on this one?

Thanks,

Carlos.
 
C

Carlos

In other words, I just want to save the contents
of variables for the next postback. Is that possible?

Thanks again,

Carlos
 
M

Mark Fitzpatrick

Try using the Viewstate. It's there in order to persist variables and
objects between page displays. One thing though, for performanec it's best
to set the enableviewstate property on controls that don't need to maintain
their viewstate. This will speed up loading and postback of the page.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 

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

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top