简体   繁体   中英

storing a double type value from html textbox into a c# variable

Does anyone know that how to store a double type value from html textbox into ac# variable? I have a html textbox with Id txtCost and that will hold a double value. Thanks in advance.

You need to parse the value using double.Parse() like so:

var value = double.Parse(txtCost.Text);

Although parsing numerical values has some globalization caveats (like how it parses dots and commas). You can read more about the parse method at MSDN

Double val=Convert.ToDouble(txtCost.Text);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM