I have a view (named searchForm) that contain input tag to picking time and search and show it in "other View Page" (searcheResultPage), But i have a great problem that after calling method when i fetch values (List) from db it doesnt go to the other view(searcheResultPage)? Also i try to do that by passing data by redirect in controller between searchForm & searcheResultPage, but when i want to redirect to other view it doesnt pass fetched List and page will show empty?
first page
<div class="input-field col m6 s12">
<input data-jdp id="date" type="text"> ==> data-jdp: for persian calendar
<label class="contact-input" for="date">Date</label>
</div>
<button id="getArchiveWarm" class="waves z-depth-4 mr-1 mb-2"> searchForCars</button>
Controller :
public ActionResult searchForm(DateTime fromTime, string driver)
{
var result = secondPage(fromTime, driver);
return View(result);
}
public List<be.Dto.warmValuesDto> secondPage(DateTime fromTime, string driver)
{
var result = _context.searching(fromTime, driver); <== it returns a List by 20 element
return result;
}
Jquery to Post Function :
$('#getArchiveWarm').click(function (event) {
$.post("/Main/searchForm", { fromTime: input0, driver:Name})
}
secondPage
@model List<be.Dto.warmValuesDto>
@foreach (var i in Model)
{ <tr>
<th>@(p=p+1)</th>
<td>@i.WarmCarNumber</td>
<td>@i.WarmCarDriverName</td>
</tr>
}
Jquery will not redirect to the pag,so you can try to post the form to the action rather than using jquery: