Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with variable?

Status
Not open for further replies.

neomax

Programmer
Jul 1, 2006
29
BG
Hi:)
My code is very simple,it's one class with some "public void" methods. I'm using 3 "int" variables in that methods. Problem is that value of variables is not transfering from one to another method.
For example:
public class Alabala
{
int x;
public void ButtonClick()
{
int x=4:
}
public void ButtonClick2()
{
x=x+1
}
message.Text = "x =" + x;
}

Output is: x = 0

That is problem, I cant use my variable!! I want to have
output like this x=5.

I thinlk I was clear:)



 
change:

public void ButtonClick()
{
int x=4:
}


to:
public void ButtonClick()
{
x=4:
}


Known is handfull, Unknown is worldfull
 
oops,

u have to use ViewState dude, variables are NOT passed between posts (which is wht happens between 2 clicks)...

try this:
public class Alabala
{
public void ButtonClick()
{
ViewState("x")=4;
}
public void ButtonClick2()
{
ViewState("x")=ViewState("x")+1
}
message.Text = "x =" + ViewState("x");
}



Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top