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

162
Vistas
How to pass list from controller to view and display

I try get datetime value from user and return selected screening of movie. Controller passed list to view, but html doesn't change.

Contoller

public ActionResult GetScreenings()
            {
                return View();
            }
    [HttpPost]
    public ActionResult GetScreenings(string starteDateTime, string endDateTime, string movieTitle)
    {
        List<ScreeningDisplayDTO> screeningsList = new List<ScreeningDisplayDTO>();
        if (String.IsNullOrEmpty(movieTitle))
        {
            screeningsList = screeningDisplayService.GetScreeningByParametr(starteDateTime, endDateTime).ToList();
        }
        else
        {
            screeningsList = screeningDisplayService.GetScreeningByParametr(starteDateTime, endDateTime, movieTitle).ToList();

        }
        return View(screeningsList);

    }

View

 @if (Model != null && Model.Count() > 0)
                {
                    foreach (var screening in Model)
                    {
                        
                       <p class="offer-film-title">@screening.MovieTitle</p>
                    }
                }

Ajax

$.ajax({
        traditional: true,
        type: "POST",
        url: '@Url.Action("GetScreenings")',
        data: { 'starteDateTime': starteDateTime, 'endDateTime': endDateTime, 'movieTitle': movieTitle  },
        success: function () {
            window.location.href = data;
        }
    });

Thanks for help.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you want to use ajax to change your view , you have to use a partial view

<div id="partialView">
    
    <partial name="_PartialView" />
        
    </div>

and return this partial view from the action and render :

  success: function (result) {
             $("#partialView").html(result);
        }

Maybe it would be easier for you to use a submit button.

over 4 years ago · Santiago Trujillo Denunciar
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