Click here to Skip to main content
15,914,444 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Calling a Win32 dll from ASP.NET. Pin
Christian Graus16-Jul-09 7:01
protectorChristian Graus16-Jul-09 7:01 
AnswerRe: Calling a Win32 dll from ASP.NET. Pin
Christian Graus16-Jul-09 7:00
protectorChristian Graus16-Jul-09 7:00 
QuestionCan’t get GridView RowIndex. Pin
enipla16-Jul-09 5:08
enipla16-Jul-09 5:08 
AnswerRe: Can’t get GridView RowIndex. Pin
Abhijit Jana16-Jul-09 5:53
professionalAbhijit Jana16-Jul-09 5:53 
GeneralRe: Can’t get GridView RowIndex. Pin
enipla16-Jul-09 5:55
enipla16-Jul-09 5:55 
QuestionCalling functions in a win32 dll from vb.net application. Pin
ashwath197916-Jul-09 5:00
ashwath197916-Jul-09 5:00 
AnswerRe: Calling functions in a win32 dll from vb.net application. Pin
Abhijit Jana16-Jul-09 5:56
professionalAbhijit Jana16-Jul-09 5:56 
QuestionMysterious FormatException for Convert.ToInt32()... Pin
chanakya3316-Jul-09 4:58
chanakya3316-Jul-09 4:58 
Cheers to all the mavens out there on codeproject!

I've banged my head over this one for some time, and I don't understand the reason for this FormatException (log entry) as thrown by Convert.ToInt32 that uses an input value from an ASP .NET 2.0 form *with* validation:

ERROR 16 Jul 2009 09:01:13,970 (Webpage code-behind class name) - Failed conversion of value
System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at (name of calling function in ASP.NET code-behind)


The code-behind of the web page is as follows:

try
{
    dataObject.Weight = Convert.ToInt32(txbWeight.Text);
}
catch (Exception e)
{
    log.Error("Failed conversion of value", e);
}


And the web page has the following validation for the txbWeight TextBox control:

<asp:CompareValidator runat="server" ControlToValidate="txbWeight" Type="Integer" 
Operator="GreaterThanEqual" ValueToCompare="0" Text="Positive number only for weight."
Display="Dynamic" />


I don't understand why this exception is thrown, because the validator ensures that an integer is being received from the user (txbWeight also has a RequiredFieldValidator). The odd thing is that dataObject receives the value despite the exception being thrown!? I don't believe I need to call Trim(), and trying this in the past did not fix the issue.

Any ideas?
AnswerRe: Mysterious FormatException for Convert.ToInt32()... Pin
Christian Graus16-Jul-09 7:04
protectorChristian Graus16-Jul-09 7:04 
GeneralRe: Mysterious FormatException for Convert.ToInt32()... Pin
chanakya3316-Jul-09 7:41
chanakya3316-Jul-09 7:41 
QuestionHow I can call a javascript function on Treeview Node Click/Select Pin
Qasim198416-Jul-09 3:23
professionalQasim198416-Jul-09 3:23 
Questionjunk mail problem Pin
Mogamboo_Khush_Hua16-Jul-09 3:12
Mogamboo_Khush_Hua16-Jul-09 3:12 
AnswerRe: junk mail problem Pin
Abhishek Sur16-Jul-09 3:18
professionalAbhishek Sur16-Jul-09 3:18 
GeneralRe: junk mail problem Pin
Mogamboo_Khush_Hua16-Jul-09 3:34
Mogamboo_Khush_Hua16-Jul-09 3:34 
GeneralRe: junk mail problem Pin
Mogamboo_Khush_Hua16-Jul-09 3:36
Mogamboo_Khush_Hua16-Jul-09 3:36 
AnswerRe: junk mail problem Pin
Tamer Oz16-Jul-09 3:25
Tamer Oz16-Jul-09 3:25 
QuestionImage preview Pin
Rijz16-Jul-09 3:11
Rijz16-Jul-09 3:11 
AnswerRe: Image preview Pin
Abhishek Sur16-Jul-09 3:14
professionalAbhishek Sur16-Jul-09 3:14 
GeneralRe: Image preview Pin
Rijz16-Jul-09 3:24
Rijz16-Jul-09 3:24 
GeneralRe: Image preview Pin
Enver Maroshi16-Jul-09 4:02
Enver Maroshi16-Jul-09 4:02 
GeneralRe: Image preview Pin
Rijz16-Jul-09 18:46
Rijz16-Jul-09 18:46 
QuestionBinding Data from Dataset to asp table Pin
getaccessyr16-Jul-09 2:53
getaccessyr16-Jul-09 2:53 
AnswerRe: Binding Data from Dataset to asp table Pin
K030616-Jul-09 3:00
K030616-Jul-09 3:00 
AnswerRe: Binding Data from Dataset to asp table Pin
Muhammad Mazhar16-Jul-09 3:13
Muhammad Mazhar16-Jul-09 3:13 
QuestionSystem.Configuration.ConfigurationManager.AppSettings Pin
Member 426027016-Jul-09 2:14
Member 426027016-Jul-09 2:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.