I am trying to convert a text-box in my form into an integer so that I can code a condition based on a numeric value. I have tried…
…to no avail. I get the error…
Exception Details: System.FormatException: Input string was not in a correct format.
Does someone know how I can successfully do this?
Where is this condition written? Is it in the .NET code behind or a field validation condition? (Required/Readonly/Hidden)
The value is probably empty when the condition is applied. Simply put
textBox.Text != String.Empty && Int32.Parse(textbox.Text)...
It’s not in the code behind. It’s in the validation tab of the element within the Hidden box. I have…
ExtFieldTripRequest_NoStudentsParticipating.Text != String.Empty && Int32.Parse(ExtFieldTripRequest_NoStudentsParticipating.Text) < ExtFieldTripRequest_MaleChaperones.SelectedValue
The error now is…
Compiler Error Message: CS0019: Operator ‘<’ cannot be applied to operands of type ‘int’ and ‘string’
I guess it’s still not converting.
Int32.Parse(ExtFieldTripRequest_NoStudentsParticipating.Text) is an integer
ExtFieldTripRequest_MaleChaperones.SelectedValue is a string.
You need to convert the second value to an integer as well in order for the comparison to work:
I have bypassed the error. The goal is to get a Read Text Only element to hide if…
ExtFieldTripRequest_NoStudentsParticipating.Text != String.Empty && (Int32.Parse(ExtFieldTripRequest_NoStudentsParticipating.Text)/10) < Int32.Parse(ExtFieldTripRequest_TotAdditionalChaperones.Text)
…is true. The NoStudentsParticipating.Text textbox fills with a number after two other fields are changed (using onchange). The TotAdditionalChaperones.Text is doing the same thing for two other fields (using onchange). I’m not sure why it isn’t evaluating after having both numbers populated in there.
Kindly open a ticket in our Helpdesk system if you require further assistance for this.