This is a migrated thread and some comments may be shown as answers.

[Solved] CurrencyTextBoxFor issue

1 Answer 193 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Diego
Top achievements
Rank 1
Diego asked on 30 Mar 2011, 05:15 PM
Hi People, I'm getting an error when I use CurrencyTextBox control. The problem is happened when I write a value higher than Max Value. Here is the code which is included in the view.

<% Html.Telerik().CurrencyTextBoxFor(m => m.Bid.BidAmount)
                           .MinValue(0)
                           .MaxValue(922337203685477.5807)
                           .ButtonTitleUp("Increase Bid")
                           .ButtonTitleDown("Decrease Bid")
                           .InputHtmlAttributes(new { @class = "bidValue", @style = "width: 200px" })
                           .Name("BidAmount")
                           .Render(); %>
                    <%= Html.ValidationMessage("BidAmount", "*", new { @style = "color:#ff0000" })%>


So the first Time m.Bid.BidAmount is 922337203685477.6 which is a higher than the Max value. My controller asks if the bidAmount is higher, and if that's correct m.Bid.BidAmount =0, so when it goes back to the view  m.Bid.BidAmount  is equals 0 , anyway I got an error
"Object Not set an instance of an object". which has not sense, cause the value is 0 which is the MinValue.

I would like to know if there exists some property like MaxLength, which could be helpful for me to avoid user  write a value higher than the Max Value

Thanks a lot

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 31 Mar 2011, 09:49 AM
Hello Diego,

 
Thank you for contacting us.

MaxValue (922337203685477.5807) is a valid decimal number, but unfortunately it exceeds maximum value which JavaScript Number object can represent. JavaScript numbers are 8bytes floating point numbers. They are reliable up to 15 digits. In other words number "922337203685477" could have only one digit after decimal point. You can check this link for more information.

After all that said in order to avoid this erroneous behavior I will suggest you set MaxValue to "922337203685477.6".

Kind regards,
Georgi Krustev
the Telerik team
Tags
General Discussions
Asked by
Diego
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or