Atta Kumah

Atta Kumah

  • NA
  • 167
  • 11.5k

Continue Adding Value from TextBox

Jun 18 2020 3:42 PM
Please Guys
 
I want to add every value i enter in a textbox continuously. But i always get result once.
 
say i enter :
 
10+10=20
20+30=50
50+5=55.....
 
With every value i enter in the textbox adding to the result.
 
In fact it work well in windows Forms but not working well in mvc and web forms.
 
See the code Below
  1. int Total = 0;  
  2. int Adxer;  
  3. protected void Button1_Click(object sender, EventArgs e)  
  4. {  
  5. int Amount = Convert.ToInt32(TextBox1.Text);  
  6. Adxer = Total - Amount;  
  7. Total = Adxer;  
  8. Label1.Text = Total.ToString();  
  9. }  
  10. MVC Code  
  11. public ActionResult OscarProRe( int Amount=0)  
  12. {  
  13. if(btn != null)  
  14. {  
  15. int addy = Amount;  
  16. int Total;  
  17. Total = userB + addy;  
  18. userB = Total;  
  19. ViewBag.To = userB;  
  20. }  
  21. }  
Please in mvc the value does not add to the result.
 
Help me find out where i got it wrong
 
Any answer is Warmly welcome. Thanks

Answers (1)