This question is locked. New answers and comments are not allowed.
Good day,
I noticed there's an issue with NumericTextBox regarding smaller value types than Int, I reviewed the telerik source from codeplex and made a few small changes, but essentially the following code fixes the problem:
The main issue on the NumericTextBox is that it sets the default MaxValue to Int32.MaxValue, which generates an error when the generic type is something like byte or short, but also produces a logical problem if the type is double or long considering the max value of Int32 is much smaller than the aforementioned.
I also used the same code from above to change the IntegerTextBox to have similiar functionality such as the NumericTextBox in regards to using generic parameters using the same code and making changes (effectively, all of the code for IntegerTextBox ended up almost identical to the NumericTextBox with only the DecimalDigits value being default to 0).
Of coarse error check would be somewhat necessary, but in our case not so much required.
Hope to see this change in Telerik MVC Extensions code as well soon, will be using my custom build so long :)
I noticed there's an issue with NumericTextBox regarding smaller value types than Int, I reviewed the telerik source from codeplex and made a few small changes, but essentially the following code fixes the problem:
TValue defaultT = default(TValue); Type targetType = typeof(TValue); MinValue = (TValue)targetType.GetField("MinValue").GetValue(defaultT); MaxValue = (TValue)targetType.GetField("MaxValue").GetValue(defaultT); IncrementStep = (TValue)Convert.ChangeType(1, targetType);
The main issue on the NumericTextBox is that it sets the default MaxValue to Int32.MaxValue, which generates an error when the generic type is something like byte or short, but also produces a logical problem if the type is double or long considering the max value of Int32 is much smaller than the aforementioned.
I also used the same code from above to change the IntegerTextBox to have similiar functionality such as the NumericTextBox in regards to using generic parameters using the same code and making changes (effectively, all of the code for IntegerTextBox ended up almost identical to the NumericTextBox with only the DecimalDigits value being default to 0).
Of coarse error check would be somewhat necessary, but in our case not so much required.
Hope to see this change in Telerik MVC Extensions code as well soon, will be using my custom build so long :)