I have a helper method as follows.
@helper DisplayTrendIndicator(double lastYear, double twoYearsAgo)
{
if (lastYear > twoYearsAgo)
{
<img id="green" src="@VirtualPathUtility.ToAbsolute("~/images/up.png")" />
}
else
{
<img id="red" src="@VirtualPathUtility.ToAbsolute("~/images/down.png")" />
}
}
When I try to invoke the method in my program, I get an "Input string was not in a correct format". This is how I call the above helper
@Helpers.DisplayTrendIndicator(double.parse(lastYear.Content), double.parse(twoYearsAgo.Content))
Note: lastYear and twoYears ago are variables returned from an API call. I'm working on an ASP.NET MVC Project C#. How do I prevent this error from popping up.
@in razor? You could have it in your model and call it like@Model.DisplayTrendIndicatordouble.Parsecalls and the string that you are passing is not in the format of adouble.