Newbies Question on data variables

V

Vivian

I have an aspx page with C# with several "post" button. Each button will do
sth, and return some data to the same page. The problem is I have a public
variable, say tmpA in C# in which data will set while the first button is
clicked. I need to get the value of tmpA when pressing other button, the
problem is how can I save the value of tmpA?
Do I need to add a hidden field on the form to do that?
Or is there any better approach? Thanks
 
E

Eliyahu Goldin

Are you asking how to preserve variables between postbacks? If this is what
you mean, put them in the VewState:

int tempA;
....
ViewState["TEMPA"] = tempA;
....
tempA = (int)ViewState["TEMPA"];
 
V

Vivian

Thanks. That's what I need.

Eliyahu Goldin said:
Are you asking how to preserve variables between postbacks? If this is
what you mean, put them in the VewState:

int tempA;
...
ViewState["TEMPA"] = tempA;
...
tempA = (int)ViewState["TEMPA"];
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

Vivian said:
I have an aspx page with C# with several "post" button. Each button will
do sth, and return some data to the same page. The problem is I have a
public variable, say tmpA in C# in which data will set while the first
button is clicked. I need to get the value of tmpA when pressing other
button, the problem is how can I save the value of tmpA?
Do I need to add a hidden field on the form to do that?
Or is there any better approach? Thanks
 

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,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top