Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
How to show/hide an input based on the selected item in another drop down list in .net core 2.1 MVC

I have this drop down list:

<div class="form-group" id="businessEntitiesIdsLegal">
    <label asp-for="BusinessEntityTypeId" class="control-label col-sm-4 col-lg-3" asp-show-required-charachter="true">Some label</label>
    <div class="col-sm-5 col-md-4 col-lg-3">
        <select asp-for="BusinessEntityTypeId" id="BusinessEntityTypeId" asp-items="Model.BusinessEntities" class="select2 select-block-level search">
            <option value="@BaseViewModel.NotSelected">Choose something</option>
        </select>
        <span asp-validation-for="BusinessEntityTypeId" class="text-danger"></span>
    </div>
</div>

and I would like to handle if its selected item with value=2 then to show this div (and also if item get changed, to hide the div):

@if(Model.BuyerTypeId == BuyerTypeEnum.Legal.Id)
{
    <div class="form-group" id="foobar">
        <label asp-for="Jbkjs" class="control-label col-sm-4 col-lg-3"></label>
        <div class="col-sm-5">
            <input asp-for="Jbkjs" type="text" class="form-control" maxlength="5">
            <span asp-validation-for="Jbkjs" class="text-danger"></span>
        </div>
    </div>
}

How can I achieve this?

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda