Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Temporary or Session Variable

What would be the proper syntax in ASP.NEt 3.5 C# to assign a TextBox value to a temporary or session variable to be manipulated (added, subtracted, multiplied, divided) at different points in the application? I want to add a decimal number to this variable in almost every instance as well.

like image 447
Jason Avatar asked Feb 25 '23 16:02

Jason


2 Answers

Session["MyValue"] = Convert.ToDecimal(textBox1.Text);

decimal myValue = Convert.ToDecimal(Session["MyValue"]);

is this what you want?

like image 124
Davita Avatar answered Feb 28 '23 05:02

Davita


Something along the lines of:

Session["decimalnumber"] = 1 //Your value

decimal number = (decimal)Session["decimalnumber"]

This assigns 1 into a session variable - then gets it back out as an decimal

like image 22
m.edmondson Avatar answered Feb 28 '23 05:02

m.edmondson