I'm using @Html.HiddenFor
to create the hidden input.
After carefully reading Scott's post I saw that he mentions the round-trip specifier. I also found an example here on StackOverflow.
The R stands for "round-trip". From MSDN:
This format is supported only for the Single and Double types. The round-trip specifier guarantees that a numeric value converted to a string will be parsed back into the same numeric value.
So I did this:
@Html.HiddenFor(m => m.Maximum,
new { Value = Model.Maximum.ToString("R") })
Now this gives me a double.MAX
string representation that can be round-tripped back to a double
on the controller side:
1.7976931348623157E+308
Nice... problem solved.
Hope it helps anyone that might face this same problem in the future.
How interesting this is?!
1.79769313486232E+308 // double.MAX
1.7976931348623157E+308 // double.MAX.ToString("R")
It's worth mentioning that all this is also applicable to double.MIN
.