Temporary or temporary ASP.NET variable

What will be the correct syntax in ASP.NEt 3.5 C # to assign a TextBox value to a temporary or temporary variable that needs to be manipulated (add, subtract, multiply, divide) at different points in the application? I want to add a decimal number to this variable in almost every instance.

+4
source share
3 answers
Session["MyValue"] = Convert.ToDecimal(textBox1.Text); decimal myValue = Convert.ToDecimal(Session["MyValue"]); 

Is this what you want?

+6
source

Something along the lines of:

 Session["decimalnumber"] = 1 //Your value decimal number = (decimal)Session["decimalnumber"] 

This assigns 1 to the session variable - then returns it as a decimal

+1
source

if you need the value of the text field at another point in the application, then it is best to choose a session. therefore, the value of the text field is assigned to the session variable. and when u wants this value then converts it to decimal and uses this session variable ...

 Session["SessionVariableName"] = txtpass.Text; decimal VariableName = (decimal)Session["SessionVariableName"]; //Or decimal VariableName = Convert.ToDecimal(Session["SessionVariableName"]); 

Hope this helps you ....

+1
source

All Articles