Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!