Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
C# Core MVC Razor Duplicate Fields AutoFill/Complete

I have a page in my C# Core project (MVC using Razor Pages) that I have duplicate types of information. In this case it is a Model that contains both delivery address information and also billing address information. So my model looks like this:

    [Display(Name = "Name")]
    [Required(ErrorMessage = "Required")]
    public string BillingName { get; set; }

    [Display(Name = "Address Line 1")]
    [Required(ErrorMessage = "Required")]
    public string BillingAddress1 { get; set; }

    [Display(Name = "Address Line 2")]
    public string BillingAddress2 { get; set; }

    [Display(Name = "Town")]
    [Required(ErrorMessage = "Required")]
    public string BillingTown { get; set; }

    [Display(Name = "County")]
    public string BillingCounty { get; set; }

    [Display(Name = "Postcode")]
    [Required(ErrorMessage = "Required")]
    public string BillingPostCode { get; set; }

    [Display(Name = "Name")]
    [Required(ErrorMessage = "Required")]
    public string DeliveryName { get; set; }

    [Display(Name = "Address Line 1")]
    [Required(ErrorMessage = "Required")]
    public string DeliveryAddress1 { get; set; }

    [Display(Name = "Address Line 2")]
    public string DeliveryAddress2 { get; set; }

    [Display(Name = "Town")]
    [Required(ErrorMessage = "Required")]
    public string DeliveryTown { get; set; }

    [Display(Name = "County")]
    public string DeliveryCounty { get; set; }

    [Display(Name = "Postcode")]
    [Required(ErrorMessage = "Required")]
    public string DeliveryPostCode { get; set; }

So when I render this on the page using

<input asp-for="BillingName " class="form-control" />

It renders the input fields fine and their corresponding id and name would be (in this case) BillingName.

<input class="form-control" type="text" data-val="true" data-val-required="Required" id="BillingName" name="BillingName" value="">

This is fine, but I need the chrome auto-fill / auto-complete to try and fill this BillingName with their Name. But because the field has an id and name of BillingName, Chrome knows nothing about this.

Is there a way to have the id="BillingName" and the name="Name"? So I could then have another field: id="DeliveryName" and the name="Name"

But, I need the model binding to still work to the ID when the form is posted back.

Any advice please?

Thank you.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda