Skip to content

[MVC] When inserting a decimal in the Razor view, I got the number without decimal in the viewmodel #17

@advapiIT

Description

@advapiIT

I got an application I migrated from 5.3.4 -> 6 and I realized that when I type 20.1 in the input field, I got 201 in the ViewModel.
I created a new project from scratch and it works... I really don't understand what can be gone wrong

 public class CreateMetalloViewModel
        {
            [Required]
            [StringLength(128)]
            public string Metallo { get; set; }

            [Required]
            [Display(Name ="Euro)]
            public float Euro{ get; set; }
        }

here I got 201 for Item.Euro

    public async Task<IActionResult> OnPostAsync()
        {
            var dto = ObjectMapper.Map<CreateMetalloViewModel, CreateOrUpdateAnagraficaMetalloDto>(Item);
            await _anagraficaMetalloAppService.CreateAsync(dto);
            return NoContent();
        }

And the form is really simple

<abp-dynamic-form abp-model="Item" asp-page="/Anagrafiche/Metalli/CreateModal">
    <abp-modal>
        <abp-modal-header title="Aggiungi nuovo metallo"></abp-modal-header>
        <abp-modal-body>
            <abp-form-content />
        </abp-modal-body>
        <abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
    </abp-modal>
</abp-dynamic-form>

Any suggestion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions