We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Value decimal not working

I have the following numeric textbox component:

<input id="priceTextBoxEdit" name="Price" />

<script type="text/javascript">
    function runPriceTextBoxEdit() {
        let numericTextBox = new ej.inputs.NumericTextBox({
            currency: "EUR",
            decimals: 4,
            format: "c4",
            min: 1.0,
            placeholder: "Price",
            step: 1.0,
            value: @Model.Price.ToString().Replace(",", ".")
        });
        numericTextBox.appendTo('#priceTextBoxEdit');
    }
</script>

When I insert a decimal such as 2.50 it's displayed it correctly but when I submit the form, my Model.Price (public decimal? Price { get; set; }) is 250 and not 2.52.
The dot is removed.. Why? Where could be the problem?

Thanks

1 Reply

CI Christopher Issac Sunder K Syncfusion Team November 19, 2018 11:24 AM UTC

Hi Mini, 

Thank you for contacting Syncfusion support. 

We have checked your reported issue and provided code block at our end. It seems you are using decimal data(value: @Model.value.ToString().Replace(",", ".")) which is unclear for us. You don’t need to do the replace operation in NumericTextBox component initialization. Could you please ensure the bounded NumericTextBox data value and datatype at your end? 


The NumericTextBox has a text input, so we can assign the NumericTextBox component value as string datatype. If you are unable to resolve the problem on above suggestion, you can specify the Form Post back data as string to resolve it. 


[HttpPost] 
public IActionResult Index(string Price) 
{ 
   return Content($"NumericTextBox value is: {Price}"); 
} 

Please let us know if you need any further assistance on this. 

Thanks, 
Christo

Loader.
Live Chat Icon For mobile
Up arrow icon