What would be the p开发者_如何学运维roper 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.
Session["MyValue"] = Convert.ToDecimal(textBox1.Text);
decimal myValue = Convert.ToDecimal(Session["MyValue"]);
is this what you want?
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
if you want the value of the textbox at different point of the application then session is best choice. so value of the textbox give to the session variable. and when u want that value then convert it to the decimal and the use that session variable...
Session["SessionVariableName"] = txtpass.Text;
decimal VariableName = (decimal)Session["SessionVariableName"];
//Or
decimal VariableName = Convert.ToDecimal(Session["SessionVariableName"]);
Hope this will helps you....
精彩评论