Click to See Complete Forum and Search --> : Input string was not in correct format


tis707
October 1st, 2008, 06:35 AM
Hi all

The application is running correctly in localhost
and when i place it in web server
iam getting this error


Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2752835
System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) +113
System.Double.Parse(String s, NumberStyles style, NumberFormatInfo info) +188
System.Convert.ToDouble(String value) +68
_Default.CalcAirCoolCapac() +102
_Default.Page_Load(Object sender, EventArgs e) +42
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42



Pls help me

boudino
October 1st, 2008, 07:06 AM
Very likely, there is another locale set on server than was on the box where the application was developed. So, application on the server expects the number in other format (e.g. "," instead of "." as decimal point) than you were used to be.

I would recommend you to use overload version of ToDouble() which accepts format provider and pass the CultureInfo in which the input is expected to be as parameter, or maybe better, use Double.TryParse() method to convert the input string into the number.

tis707
October 1st, 2008, 07:24 AM
Thanks for reply

I am using
if(txtinput.text != "")
double i = Convert.ToDouble(txtinput.text)

how can i pass culture info into that

pls help me

boudino
October 1st, 2008, 09:01 AM
E.g. with Convert.ToDouble(txtinput.text, CultureInfor.InvariantCulture). Of course, see CultureInfo class reference (especialy GetCultureInfo static method) to learn how to get the CultureInfo, which exactly meet your needs.

tis707
October 1st, 2008, 09:31 AM
Thanks a lot
now by using double.TryParse its working

i will look into cultureinfo and change accodingly

Thank you