I am well aware that there are similar question to my question but it they does not answer my question properly.
My main problem is that whenever I click the update button in my view this is where it brings me to
https://localhost:44332/Clique/AdminDashboard?Start=2021-07-21&End=2021-07-20
but I want it to take me to
https://localhost:44332/Clique/UpdateTotalServed?Start=2021-07-21&End=2021-07-20
Here is the code of my back-end
public ActionResult AdminDashboard()
{
QTableEntities db = new QTableEntities();
return View(db.QTables.ToList());
}
public ActionResult UpdateTotalServed(DateTime Start, DateTime End)
{
QTableEntities db = new QTableEntities();
var a = db.QTables.Where(x => x.QDate > Start).ToList();
var b = a.Where(x => x.QDate < End).ToList();
return View("AdminDashboard", b);
}
and here is the code of my front-end
@using (Html.BeginForm("UpdateTotalServed", "Clique", FormMethod.Post))
{
<br><label for="">FROM</label>
@Html.TextBox("Start", null, new { type = "date" })
<label for="">TO</label>
@Html.TextBox("End", null, new { type = "date" })
<input type="submit" , class="btn btn-month-year" value="UPDATE" />
}
GOT my answers: I had
I think you're missing
[HttpPost]
attribute on your update method
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.